The example in this article describes how jQuery uses the after() method to add multiple contents after the element. Share it with everyone for your reference. The specific analysis is as follows:
jQuery can add multiple contents after the element through the after() method. after() can take multiple parameters and add multiple contents after the specified element
<!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"> </script> <script> function afterText() { var txt1="<b>I </b>"; // Create element with HTML var txt2=$("<i></i>").text("love "); // Create with jQuery var txt3=document.createElement("big"); // Create with DOM txt3.innerHTML="jQuery!"; $("img").after(txt1,txt2,txt3); // Insert new elements after img } </script> </head> <body> <img src="/images/w3jquery.gif" alt="jQuery" width="100" height="140"> <br><br> <button onclick="afterText()">Insert after</button> </body> </html>
I hope this article will be helpful to everyone’s jQuery programming.