jQuery USES the after of method to add multiple items after an element
- 2020-05-19 04:15:26
- OfStack
This example shows how jQuery USES the after() method to add multiple items after an element. Share with you for your reference. The specific analysis is as follows:
jQuery can add multiple things after an element through the after() method, and after() can add multiple things after a specified element with multiple arguments
<!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 has helped you with your jQuery programming.