jquery Remove TR Invalid workaround

Source: Internet
Author: User

One of the problems in doing the project today is to remove some TR (tr is dynamically added). Try a lot of ways, it doesn't work (for example, the DeleteRow method, the seemingly passed parameter can only be the number of TR rows.) Not carefully studied presently). Later, this method was found to be of great effect and is hereby recorded.

1 2 $ (temp). Parent (). remove (); TEMP for TD ID code class= "JS Plain" > My understanding Is this: $ (temp) Gets the TD object First, then. Parent () Gets the TR, remove () method of TD, and deletes tr. </code>

HTML code:

1 2 3 4 5 6 7 8 9 10 <table> <tr> <td><a href= ' # ' onclick= ' Removetr (this) ' >123</a></td> <td> <a href= ' # ' onclick= ' Removetr (this) ' >456</a></td> </tr> <tr> <td><a href= ' # Onclick= ' Removetr (this) ' >aaa</a></td> <td><a href= ' @ ' onclick= ' removetr (this) ' >bbb< /a></td> </tr>;/table>

JS Code:

1 2 3 4 function Removetr (temp) {MP). Parent (). Parent (). remove (); It must be guaranteed that the page has been introduced to jquery for use//here $ (temp) Gets the <a> object first,. Parent () get <td> parent () Get to TR}

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.