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 jquery adds content after a specified element

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains the "jquery how to add content after the specified elements", the content in the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "jquery how to add content after the specified elements" bar!

Two methods: 1, with after (), syntax "$(specified element). After (" new content ")", you can add specified content to the specified element. 2. With insertAfter (), the syntax "$(" content value "). InsertAfter (specified element)", the content can be inserted after the specified element.

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

How does jquery add content after a specified element

To add content after the specified element is to insert the sibling element after the specified element. Jquery provides two methods:

After ()

InsertAfter ()

Both after () and insertAfter () can insert the specified content after the selected element, but their operands are upside down. Let's introduce it in detail.

1. Use after ()

$(A) .after (B) means to insert B after the outside of A.

Example:

$(document) .ready (function () {$("button") .click (function () {$("div"). After ("this is new text content added after div");}) Here are some texts.

This is a p paragraph in the div block.

Add content after div

2. Use insertAfter ()

$(A) .insertAfter (B) means to insert An after the outside of B.

Example:

$(document) .ready (function () {$("button") .click (function () {$("this is a new span element") .insertAfter ("div");}) Here are some texts.

This is a p paragraph in the div block.

Add content after div

Thank you for reading, the above is the content of "jquery how to add content after the specified elements", after the study of this article, I believe you have a deeper understanding of how jquery adds content after the specified elements, 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