Home > Web Front-end > JS Tutorial > jQuery uses append to add multiple contents at the same time after html elements_jquery

jQuery uses append to add multiple contents at the same time after html elements_jquery

WBOY
Release: 2016-05-16 16:07:29
Original
1363 people have browsed it

The example in this article describes how jQuery uses append to add multiple contents at the same time after the html element. Share it with everyone for your reference. The specific analysis is as follows:

The following code can add multiple contents after a text paragraph at the same time

<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
function appendText()
{
var txt1="<p>Text.</p>"; // Create text with HTML
var txt2=$("<p></p>").text("Text."); // Create text with jQuery
var txt3=document.createElement("p");
txt3.innerHTML="Text."; // Create text with DOM
$("body").append(txt1,txt2,txt3); // Append new elements
}
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button onclick="appendText()">Append text</button>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template