Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  144] [ 1]  / answers: 1 / hits: 21344  / 15 Years ago, sun, february 14, 2010, 12:00:00

What sort of selector would be I need in order to insert after the parent (divouter) of the test3 class in the example below? Thanks.



<div class='divouter'>
<div class='divinner'>
<input class=test1></input>
</div>
</div>
<div class='divouter'>
<div class='divinner'>
<input class=test2></input>
</div>
</div>
<div class='divouter'>
<div class='divinner'>
<input class=test3></input>
</div>
</div>
<div class='divouter'>
<div class='divinner'>
<input class=test4></input>
</div>
</div>

More From » jquery

 Answers
49

You could use the $.after() method:



$(.test3).closest(.divouter).after(<div>Foo</div>);


Or the $.insertAfter() method:



$(<div>Foo</div>).insertAfter( $(.test3).closest(.divouter) );

[#97572] Thursday, February 11, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maurodannyr

Total Points: 126
Total Questions: 103
Total Answers: 105

Location: Maldives
Member since Sun, Feb 27, 2022
2 Years ago
;