Home  >  Article  >  Web Front-end  >  jQuery uses the after() method to add multiple contents after the element_jquery

jQuery uses the after() method to add multiple contents after the element_jquery

WBOY
WBOYOriginal
2016-05-16 16:07:171256browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn