jQuery live modifying css
Is there any w开发者_运维百科ay I can modify some style to all elements that matches a selector, even if they are created after the line of code?
A litle example: If I have a few tabs with li's I could want to do:
$("#tabs li").css("color", "black");
$("#tabs li.selected").css("color", "red");
And I would like that those lines take effect as .live
do. If after executing them selected class is added to a li, that li should be applied with the second line (color: red
).
Note: The above code is just an example, I need to do this with some style added by a jquery plugin, so there is no chance of having it on the css file.
Thanks!
I'm not sure if I am fully understanding your question but would something like this not work? http://jsfiddle.net/nickywaites/DJ6nZ/
Dynamically adding style tag http://jsfiddle.net/DJ6nZ/1/
精彩评论