In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to select and delete javascript". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to select and delete javascript"!
Javascript to achieve the method of selecting and deleting: 1, use the js function to get all the checkbox check boxes; 2, through the checked attribute to get whether the check box is selected; 3, through the parentNode attribute to get the parent node; 4, use the removeChild method to delete.
This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer
How does javascript implement selected deletion?
JS delete check box, native JS code
The html code is shown in the figure. Note that there is a class style name in checkbox.
To delete the button's event code, we first use js's function document.getElementsByClassName to get all the checkbox check boxes through the style name.
The check box you get is an array, and we get the length of the array and use the for loop to process it. Note that you need to loop back to front, otherwise you will have a problem deleting multiple ones at the same time.
Use the checked property to get whether the check box is selected.
From the selected check box, get its parent node, the corresponding div element, through the parentNode attribute.
Then use the parentNode of div to get the parent node of the uppermost layer, and then you can use the removeChild method to delete the child node, and the passed parameter is the corresponding div node.
Run the page, select a check box, click the delete button, and you can see that the selected one has been deleted successfully.
Select multiple check boxes, and then click Delete, you can also delete multiple boxes.
At this point, I believe you have a deeper understanding of "how to select and delete javascript". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.