How to remove elements without ID in HTML
This article mainly introduces how to remove the elements without ID in HTML, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Remove the HTML without ID elements: 1, use the "$(" parent element ") .children (": not ([id]) ") statement to get all the elements that need to be removed without ID; 2, use the remove () method to delete the acquired elements, and the syntax" elements without ID .remove () ".
The operating environment of this tutorial: windows7 system, HTML5&&jquery1.10.2 version, Dell G3 computer.
Remove elements in HTML that do not have ID
You can use selectors and methods in jquery to implement the code:
$(document) .ready (function () {$("# but") .click (function () {$("div") .children (": not ([id])") .remove ();}) No id title, no id title, no id div, id div.
Paragraphs without id
There are paragraphs with id.
Remove elements without ID
Description:
The children () method returns all direct child elements of the selected element.
The not () selector selects all elements except the specified element.
The [attribute] selector selects each element with the specified attribute.
The remove () method removes the selected element, including all text and child nodes.
Thank you for reading this article carefully. I hope the article "how to remove the elements without ID in HTML" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!