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 use jQuery to realize the interchange of buttons in two div

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

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use jQuery to achieve the switch of buttons in two div". The explanation in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use jQuery to achieve the exchange of buttons in two div".

The effect is as follows

The code is as follows:

$(function () {/ / define a variable equal to all button buttons var btns = $("button"); / / for loop to traverse for (var I = 0; I < btns.length) ) {/ / I controls his subscript to determine the click event of that button btns.onclick = function () {/ / determine if the parent control of this button is div1 if ($(this). Parent (). Is ("# div1")) {/ remove this button $(this). Remove () / transfer to div2 $(this) .appendto ("# div2")} else {/ / otherwise his parent control is div2, then move him to div1 $(this) .appendto ("# div1")}); div {width: 500px; height: 200px; border: 1px; background-color: beige;} button {width: 50px; height: 30px;}

What I chose:

You can also choose:

Mathematics, English, sports, art, physics, chemistry, history, geography, biology, thank you for your reading, the above is the content of "how to use jQuery to achieve the switch of buttons in two div". After the study of this article, I believe you have a deeper understanding of how to use jQuery to achieve the exchange of buttons in the two div. 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