javascript - Change element's ID multiple times -
So what I'm triying to get is that I add some other elements to an element div and its id attribute Want to change (or something like that)
I have tried to do something like
$ ('# add3'). Click (function () ($ ('# add3') .attr ("id", "add4"); $ ('third_row1'). Attachment ('something to add');});
And tried to do anything like this:
$ ('# add'). Click (function () {var vari = $ ("& lt; $ ('. Third_row1'). Add (different); $ ('third_orrow'); $ ('. Third_oro' & gt; add another user & lt ; / Div & gt; "); $ ('# add') .append ('something to add');});
So click on a button (like That second example) has no effect on the third, fourth ... click on the same thing with the second example
Thanks in advance for help
< Strong> UPD
OK, so how do I choose here, which I add
& lt; jsp: useBean id = "obj1" class = "com.Users" scope = "page" /> Whatever I want to do is add the same selection, but with different IDs and names
< Pre> $ (document) .on ("click", "text"> Since element IDs are dynamically changed, ATR ("id" "" Eddie 4 "); $ ('Third_orror') Attach ('some to add');}); # Add3 ", function () {$ ('# add3').
If all these elements ( #add
, # add3
) If the pages are inside the still element, then using this element would be better ("click", "# add3", function () { $ ("static_element_selector ") Instead of document
. / Pre> And just note: because it
indicates the clicked DOM element to click, then You can use this.id = "add4"
instead of . $ $ ('# AD3') Astrator ("ID", "AD4");
. Small and works a bit faster.
Comments
Post a Comment