Get the App
SLTechnology News&Howtos  ›  Development  › 

How does jquery remove an element from the end

Shulou Source: shulou.com Published: 2022-06-02 15:04:07 10月02日 Update

This article shows you how jquery removes an element from the end, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can learn something from the details of this article.

Removal method: 1, using "eq (- 1)" selector and remove () method, syntax "$(Element). Eq (- 1). Remove ()"; 2, using ": last" selector and remove () method, syntax "$(Element:last). Remove ()".

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

Jquery removes an element from the end

Method 1: "eq (- 1)" selector + remove () method

Use the "eq (- 1)" selector to select the last element from the end

Delete the selected element using the remove () method

$(document) .ready (function () {$("p"). Eq (- 1). Remove ();})

The first paragraph

The second paragraph

The third paragraph

The fourth paragraph

The fifth paragraph

The sixth paragraph

Method 2: ": last" selector + remove () method

Use the ": last" selector to select the last element from the end

Delete the selected element using the remove () method

$(document) .ready (function () {$("p:last") .remove ();})

The first paragraph

The second paragraph

The third paragraph

The fourth paragraph

The fifth paragraph

The above is how jquery removes an element from the end. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Methods elements selection end content skills knowledge grammar two paragraphs concise concise six paragraphs that is tutorials articles more versions environment computer articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Huawei Xiaomi NVidia