Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add sibling nodes to jquery

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to increase brother nodes in jquery". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to increase brother nodes in jquery".

Jquery add sibling node method: 1, use before (), syntax "$(specify element). Before (sibling node)", you can insert sibling node before the specified element; 2, use after (), syntax "$(specify element) .after (sibling node)", you can insert sibling node after the specified element.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

In jquery, you can use the following two methods to add sibling nodes

The before () method inserts the specified content before the selected element.

The after () method inserts the specified content after the selected element.

1. Use before () to add sibling nodes forward

Before () can insert a sibling node before the specified element

Syntax:

$(A) .before (B)

Indicates that the B sibling node is inserted in front of node A.

Example:

$(function () {$("button") .click (function () {var a = "a span element"; $("div") .before (a);})) a subtitle

A p paragraph

A div element

A p paragraph

Insert a sibling node before div

2. Use after () to add sibling nodes backward.

After () can insert a sibling node after the specified element

Syntax:

$(A) .after (B)

Indicates that the B sibling node is inserted behind the outside of node A.

Example:

$(function () {$("button") .click (function () {var a = "a span element"; $("div") .after (a);})}) A large title

A p paragraph

A div element

A p paragraph

Insert a sibling node before div

Thank you for your reading, the above is the content of "how to increase brother nodes in jquery". After the study of this article, I believe you have a deeper understanding of how to increase brother nodes in jquery, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report