How to delete the previous element in jquery

青灯夜游
Release: 2021-11-16 16:45:51
Original
3001 people have browsed it

Jquery method to delete the previous element: 1. Use the prev() method to obtain the previous element object of the specified element, syntax "$(selector).prev()"; 2. Use the remove() method to delete The previous element object obtained, the syntax is "previous element object.remove()".

How to delete the previous element in jquery

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

jquery deletes the previous element

In jquery, if you want to delete the previous element, you first need to get the previous element, this is Need to use prev() method.

prev() method returns the previous sibling element of the selected element. (Sibling elements are elements that share the same parent element.)

To obtain the previous element, you need to use the remove() method to delete it.

Implementation code:

      

第一段

第二段

第三段

第四段--#box元素

第五段

第六段

Copy after login

How to delete the previous element in jquery

Related tutorial recommendations:jQuery video tutorial

The above is the detailed content of How to delete the previous element in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!