jquery - Accessing attributes of dynamically created elements using .on function and selector paramter -


I have elements that are dynamically created and after clicking on them, the properties of one of them I want to use. I want to identify these new hair elements based on the names of these squares. I think, to add a click handler to the original element I already use. Function should be used. For example, this dynamic element would be:

  & lt; Div id = "parent" & gt; & Lt; A class = "dynamic child" id = "123" /> & Lt; A class = "dynamic child" id = "124" /> & Lt; A class = "dynamic child" id = "125" /> & Lt; / Div & gt;  

And to add this one click handler function:

  $ ('# parent'). ('Click', '.dynamicChild', function (e) {});  

My question is, in the above work, I want to use the ID of the child element that was clicked. Does anyone have any suggestions on how I can do this? My guess was low, but it does not seem to work.

  Warning ($ (this) .id);  

Thanks in advance.

Do not wrap it up yet:

  this.id //  

should work with your exact same code!

And if for some reason you have already converted it to a jQuery object, you have to explicitly get this attribute:

  $ (this) Another option: .atr ('id')  
>

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -