![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, Thank you to help me to discover jQuery. I have a very easy question but i walk around the solutions for days. //I search for sub-elements with class "test" of paragraphs : var elementSearched = $("p .test"); //Then I add a new nodes to these elements : var returnedVar = elementSearched.after("<div class="subtest">Hello</ div>"); My aim is to add handlers already present on other nodes to these new nodes. But "returnedVar" is not the new nodes added but the old one targetted. Then I have to search for the new nodes added to apply the handler. It is hard and if I apply the handler to a node already handled, my handler is done twice for this node. How can I have references to the nodes added with .after method ? Thank you for your help. |
#3
| |||
| |||
|
|
Use insertAfter() instead. See http://docs.jquery.com/Manipulation/insertAfter http://docs.jquery.com/Manipulation/insertAfter>- Richard On Thu, Nov 5, 2009 at 5:50 PM, kheraud <kher... (AT) gmail (DOT) com> wrote: Hello, Thank you to help me to discover jQuery. I have a very easy question but i walk around the solutions for days. //I search for sub-elements with class "test" of paragraphs : var elementSearched = $("p .test"); //Then I add a new nodes to these elements : var returnedVar = elementSearched.after("<div class="subtest">Hello</ div>"); My aim is to add handlers already present on other nodes to these new nodes. But "returnedVar" is not the new nodes added but the old one targetted. Then I have to search for the new nodes added to apply the handler. It is hard and if I apply the handler to a node already handled, my handler is done twice for this node. How can I have references to the nodes added with .after method ? Thank you for your help. |
![]() |
| Thread Tools | |
| Display Modes | |
| |