Adding and removing style attribute from div with jquery

前端 未结 7 2100
走了就别回头了
走了就别回头了 2021-01-30 00:53

I\'ve inherited a project I\'m working on and I\'m updating some jquery animations (very little practice with jquery).

I have a div I need to add and remove the style at

7条回答
  •  难免孤独
    2021-01-30 01:24

    You could do any of the following

    Set each style property individually:

    $("#voltaic_holder").css("position", "relative");
    

    Set multiple style properties at once:

    $("#voltaic_holder").css({"position":"relative", "top":"-75px"});
    

    Remove a specific style:

    $("#voltaic_holder").css({"top": ""});
    // or
    $("#voltaic_holder").css("top", "");
    

    Remove the entire style attribute:

    $("#voltaic_holder").removeAttr("style")
    

提交回复
热议问题