I am using jQuery to do something like:
$("#div1 .code").css('display','inline');
Now the problem is that when I add another element with class "code" inside d开发者_如何学Goiv1, it does not get the CSS tag of display inline.
How can I make it so that it always updates the CSS for any new elements part of div1.
Thank you for your time.
make a css class in the <style type='text/css'></style>
section and add that class to each div that you make. It is always best to keep styling and javascript separate, so it is easier to dbug and understand.
edit make the class .inline-div { display:inline!important }
(use important if you want to make sure it takes precedence)
Look into jQuery live
events. They will do exactly what you need.
$("#div1 , .code")
-- the comma was missing.
look at this question
Edit: You should bind with the event that creates the new element. How is the element created?
精彩评论