jQuery CSS: Dynamically change attributes of a class

后端 未结 7 1979
悲哀的现实
悲哀的现实 2020-12-09 08:33

I want to change the attribute of a class on which all element that use the class for the rest of the web application life (from start of use until the user exits the web ap

7条回答
  •  孤城傲影
    2020-12-09 08:50

    Using the css() method changes the inline styles on already existing elements, and you can't use that to change the styles on future elements. A workaround (that I don't like very much) would be to insert a style tag:

    $( "" ).appendTo( "head" )
    $("p").last().after("
    Now!
    ");

    FIDDLE

提交回复
热议问题