In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you how jquery deletes the relevant knowledge points of the element itself. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
Delete method: 1, use remove () to delete the element and all its internal contents, the syntax is "specify the element .remove ();"; 2, use children () and unwrap () to delete the element, but keep the child nodes inside, and the syntax is "specify the element .children (). Remove ();".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery deleting an element itself can be divided into two situations:
Delete the element itself and its contents (text and child nodes)
Delete only the element itself and keep the child nodes
Case 1. Use the remove () method
Use the remove () method to delete an element and everything inside it.
$(document) .ready (function () {$("button") .click (function () {$("div"). Remove ();}) Div {background-color: yellow;}
This is the paragraph in the div element.
This is the paragraph in the div element.
This is the paragraph in the div element.
Delete div element
Case 2: using the children () + unwrap () method
The children () method returns all direct child elements of the selected element.
The unwrap () method deletes the parent element of the selected element.
$(document) .ready (function () {$("button") .click (function () {$("div"). Children (). Unwrap ();})) Div {background-color: yellow;}
This is the paragraph in the div element.
This is the paragraph in the div element.
This is the paragraph in the div element.
Delete div element
The above is all the content of the article "how to delete the element itself by jquery". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.