jQuery style not being applied in Safari

前端 未结 4 1270
小鲜肉
小鲜肉 2020-12-07 01:22

I have an absolutely positioned element that I move with the help of jQuery using the CSS propertly \'left\'.

$(\"#element\").css(\'left\', \'103px\');
         


        
4条回答
  •  抹茶落季
    2020-12-07 01:53

    I faced this problem once and i end up using addClass and removeClass on elements parent container.

    try this

    $("#element").css('left', '103px').parent().addClass("dummyClass").removeClass("dummyClass");
    

    if that doesn't work follwoing will work for sure.

    $("#element").css('left', '103px');
    $("body").addClass("dummyClass").removeClass("dummyClass");
    

    the problem is sometime safari doesn't redraw the page when we change CSS so we need to force redrawing

提交回复
热议问题