JQuery remove tr invalid solution (tr is dynamically added) _ jquery

Source: Internet
Author: User
Some methods have been removed (tr is dynamically added), but they do not work. Later I found a good method. So I will share with you the following, one problem is that some tr is removed (tr is dynamically added ). The deleteRow method does not work if you try many methods. (For example, the deleteRow method does not work. It seems that the passed parameter can only be the number of lines of tr. Does not carefully study the current ). Later, I found this method works well and I would like to record it here.

$ (Temp ). parent (). remove (); // temp is the id code class = "js plain"> I understand this as follows: $ (temp) first obtains the td object, and then. parent () gets the tr of td, then remove () method, delete tr.

Html code:

Js Code:

Function removeTr (temp) {mp ). parent (). parent (). remove (); // you must ensure that jQuery has been introduced to the page before you can use it. // here $ (temp) gets the object first ,. parent () to get
;/Table>
123 456
Aaa Bbb
, And then. parent () gets tr}
Related Article

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.