In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces javascript how to obtain elements and delete related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this javascript how to obtain elements and delete the article will have a harvest, let's take a look at it.
Javascript gets and deletes the element by first getting the element object using the "document.querySelector (element name)" or "document.getElementById (id)" statement, and then deleting the element using the "element object .remove ()" statement.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
The method of getting and deleting elements by javascript
Div element function deleteChild () {/ / var div= document.querySelector ("div"); var div=document.getElementById ("div"); div.remove ();} var btn = document.getElementById ("btn"). Onclick = function () {deleteChild ();}
Effect picture:
Description:
The querySelector () method returns an element in the document that matches the specified CSS selector.
The getElementById () method returns a reference to the first object that owns the specified ID.
The remove () method can be used to delete all elements on the parent node, including all text and child nodes.
This is the end of the article on "how to get elements and delete javascript". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to get elements and delete javascript". 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.