javascript - jQuery: if hovering over an element injects something into the DOM, can I still reference it? -


If hovering on an element puts something in the DOM, can I still refer to it?

Or do I want to use the live plugin?

I'm using jQuery 1.3.2

  $ ("# someItem"). Can Attr ("src", "htt ...")  

?

I am trying to do this, but I feel that No new item is working in the dom.

Yes, an element that has been added to the DOM can be selected and referenced is.

Or, if you already had a reference to it, which you used to add to the DOM, then you can add that reference to this even after this.

By using this example, you can see that both of you can use the current context for a newly created element, as well as create a new context for it.

HTML:

& lt; Div id = 'button' & gt; Hover me & lt; / Div & gt;

jQuery:

  $ ('# button'). Remove $ ('div id = "newElement"> New element & lt; / div & gt;'); $ (' Body '). Attachments ($ myNewElement); $ myNewElement.css ({color:' red '});}, function () {// This function is the location of completely different names, which is called #newElement // Made and inserted and I can get it reference like any other element, var $ newReferenceToElement = $ ('# NewElement'); $ newReferenceToElement.css ({color: 'blue'});};  

Comments