Get the App
SLTechnology News&Howtos  ›  Development  › 

How does jquery delete the third li element

Shulou Source: shulou.com Published: 2022-05-31 18:36:31 09月15日 Update

This article mainly introduces "jquery how to delete the third li element" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "jquery how to delete the third li element" article can help you solve the problem.

Jquery delete the third li element method: 1, use ": nth-child (n)" selector to select the third li element, syntax "$(" li:nth-child (3) ")"; 2, use remove () to delete the selected element and its internal contents, syntax "specify li element .remove ()".

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

Jquery deletes the third li element

The idea of realization is:

Select the third li element

Delete the acquired li element

Implementation method:

You can use the nth-child (n) selector to select the specified location element. If you want to select the third li element, you can set li:nth-child (3)

The remove () method can be used to delete the selected element

Use the remove () method to delete an element and everything inside it.

Implementation example:

$(function () {$("button") .click (function () {$("li:nth-child (3)") .remove () }) 1st li element, 2nd li element, 3rd li element, 4th li element, 5th li Element the sixth li element deletes the third li element

This is the end of the introduction to "how jquery deletes the third li element". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Elements methods content knowledge industry grammar choices different practical location practical practical ideas tutorials articles more cases versions environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info Docker Xiaomi Huawei