jQuery CSS: Dynamically change attributes of a class

后端 未结 7 1963
悲哀的现实
悲哀的现实 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条回答
  •  萌比男神i
    2020-12-09 08:45

    Try with this: http://jsfiddle.net/tRqBV/5/

    $(function () {
       $(".myClass").css("background", "green");
       $("p").last().after("
    Now!
    "); $(document).ready(function () { $('div.myClass').css("background", $('p.myClass').first().css('background-color')); }); });

提交回复
热议问题