Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery deletes elements that match with dom

Shulou Source: shulou.com Published: 2022-05-31 16:34:55 09月19日 Update

In this article Xiaobian for you to introduce in detail "jquery how to delete dom matching elements", the content is detailed, the steps are clear, and the details are handled properly. I hope this "jquery how to delete dom matching elements" article can help you solve your doubts.

Jquery delete dom matching element method: 1, use "$()" to select dom element, syntax "$(" selector ")", will return the jquery object containing matching element; 2, use remove () to delete matching element, syntax "selected element object .remove ()", will delete element and its internal contents.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Jquery deletes elements that match with dom

1. Use $() to select the dom element

$() can be $(expresion), that is, the css selector, Xpath, or html element, which matches the target element through the above expression.

Syntax:

$("selector")

For example, the object constructed by $("a") uses a CSS selector to build a jQuery object-- it selects all of this tag.

2. Delete matching elements using remove ()

The remove () method deletes the selected element and all its internal contents.

Selected element object .remove ()

Example: select the div element and delete

$(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

After reading this, the article "jquery how to delete dom matching elements" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Element object selection content article paragraph grammar this is method proper that is ideas tutorials new knowledge more tags steps versions environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno macOS MySQL Docker