Firefox不会显示我的jquery添加元素,但Chrome会显示

时间:2021-06-02 02:24:06

HEre is my function :

是我的功能:

function addEventForm(jour){
    if(!$(".formEvent").length){
        jour.closest("tr").after("<form class='formEvent'><div class='curseur'></div></form>");
    }

    var percent = jour.offset().left-jour.closest("tr").offset().left+parseInt(jour.css("margin-left").replace("px", ""))+ parseInt(jour.css("padding-left").replace("px", ""))+parseInt(jour.css("border-left-width").replace("px", ""));
    $(".formEvent .curseur").css({"top" : "-15px" , "left": percent+"px"});
    $(".formEvent").show()
}

By invoking it on Chrome, everything is alright, but in Firefox, the element is added, but not shown. How to fix it ?

通过在Chrome上调用它,一切都很好,但在Firefox中,元素已添加,但未显示。怎么解决?

EDIT

Example : https://jsfiddle.net/g45r4um2/1/

示例:https://jsfiddle.net/g45r4um2/1/

1 个解决方案

#1


2  

I fixed it: https://jsfiddle.net/g45r4um2/13/ In firefox it doesn't understand where it has to be placed, so you have to add td and tr tags. Infact if you inspect element form in your code it is under tbody > form and seems firefox doesn't like elements under tbody alone.

我修复了它:https://jsfiddle.net/g45r4um2/13/在Firefox中,它不知道它必须放在哪里,所以你必须添加td和tr标签。事实上,如果您在代码中检查元素形式,它在tbody> form下,似乎firefox不喜欢单独的tbody下的元素。

jour.closest("tr").after("<tr><td><form class='formEvent'><div class='curseur'></div></form><td></tr>");

#1


2  

I fixed it: https://jsfiddle.net/g45r4um2/13/ In firefox it doesn't understand where it has to be placed, so you have to add td and tr tags. Infact if you inspect element form in your code it is under tbody > form and seems firefox doesn't like elements under tbody alone.

我修复了它:https://jsfiddle.net/g45r4um2/13/在Firefox中,它不知道它必须放在哪里,所以你必须添加td和tr标签。事实上,如果您在代码中检查元素形式,它在tbody> form下,似乎firefox不喜欢单独的tbody下的元素。

jour.closest("tr").after("<tr><td><form class='formEvent'><div class='curseur'></div></form><td></tr>");