Jquery is used to delete all elements after an element.

Source: Internet
Author: User
This article mainly introduces jquery's function of deleting all elements after an element, which is simple and convenient, interested friends can refer to the examples in this article to share with you the detailed implementation process of jquery to delete all elements after an element. the specific implementation content is as follows:

Effect:

Select project

Click the delete button to delete all elements of the same level after the option is selected.

The nextAll () method traversed by jQuery can be used to search for sibling elements following the elements in the DOM tree, that is, all sibling elements following an element. to delete an element, you can use the remove () method.$ (Selector). nextAll (). remove ();
The following is an example: click the button to delete all the options after the selected project
Create Html elements

Click the button to delete all options after the selected project.

RadishVegetablesScallions
TofuTudouEggplant

Set the css style

p.box{width:300px;height:200px;padding:10px 20px;border:4px dashed #ccc;}p.box>span{color:#999;font-style:italic;}p.content{width:250px;height:100px;margin:10px 0;border:1px solid green;}input{margin:10px;}input[type='button']{width:200px;height:35px;margin:10px;border:2px solid #ebbcbe;}

Compile jquery code

$(function(){ $("input:button").click(function() { $("input:checkbox:checked").next().nextAll().remove(); });})

The above are the knowledge points prepared by Xiaobian for you. I hope you can master them well.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.