In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces jquery how to add an element of related knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe you will gain after reading this jquery article on how to add an element, let's take a look at it.
Add method: 1, use the "$(" specified element "). After (new element)" statement, you can add a sibling element after the specified element; 2, use the "$(" specify element ") .before (new element)" statement, you can add the sibling element in front of the specified element; 3, use the "$(parent element). Append (child element)" statement.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, you can use the following methods to add elements:
After (): adds a sibling element to the specified element
Before (): adds sibling elements to the specified element
Append (): adds child elements to the end of the specified element
Prepend (): adds a child element to the beginning of the specified element
1. Use after ()
The after () method inserts content "behind" outside the selected element.
$(function () {$("button") .click (function () {var a = "a span element"; $("div") .after (a);}) body * {background-color:pink } A big title
A p paragraph
A div element
A p paragraph
Insert a sibling node after div
2. Use before ()
Before () can insert a sibling node before the specified element
$(function () {$("button") .click (function () {var a = "a span element"; $("div") .before (a);}) body * {background-color:pink } A big title
A p paragraph
A div element
A p paragraph
Insert a sibling node before div
3. Use append ()
The append () method inserts content into the "end" inside the selected element.
$(function () {$("button") .click (function () {var a = "a p element)
"; $(" div ") .append (a);}) body * {background-color:pink;} a big title
A p paragraph
A div element
A p paragraph
Insert a child element at the end of the div
4. Use prepend ()
The prepend () method inserts content into the "start" inside the selected element.
$(function () {$("button") .click (function () {var a = "a p element)
"; $(" div ") .prepend (a);}) body * {background-color:pink;} a big title
A p paragraph
A div element
A p paragraph
Insert a child element at the beginning of the div
This is the end of the article on "how to add an element to jquery". Thank you for reading! I believe you all have a certain understanding of "how to add an element to jquery". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.