+ 2

What is difference between append() and after()?

8th May 2017, 12:35 PM
Ashok Kumar
Ashok Kumar - avatar
1 Antwort
+ 7
$(selector).append(content) insert 'content' as last child of each selected elements. $(selector).after(content) insert 'content' after each selected elements. For example: <div> <p class="myP">1</p> <p class="myP">2</p> <p class="myP">3</p> </div> $(".myP").insert('<span>paragraphe</span>'); ... will produce: <div> <p class="myP">1<span>paragraphe</span></p> <p class="myP">2<span>paragraphe</span></p> <p class="myP">3<span>paragraphe</span></p> </div> But: $(".myP").after('<span>paragraphe</span>'); ... result as: <div> <p class="myP">1</p> <span>paragraphe</span> <p class="myP">2</p> <span>paragraphe</span> <p class="myP">3</p> <span>paragraphe</span> </div> http://api.jquery.com/append/ http://api.jquery.com/after/
8th May 2017, 4:36 PM
visph
visph - avatar