Get the App
SLTechnology News&Howtos  ›  Development  › 

How does jquery get rid of tr

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

This article mainly introduces jquery how to remove tr, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Jquery remove tr methods: 1, create a js example file; 2, introduce jQuery;3, through the "function removeTr (temp) {...}" method to remove tr.

This article operating environment: windows7 system, jquery-2.1.4 version, DELL G3 computer

JQuery remove tr

When I was working on a project today, I encountered a problem, that is, to remove some tr (tr is added dynamically). Many methods have been tried, but they don't work (for example, the deleteRow method, it seems that the parameter passed can only be the number of rows of tr. There is no careful study at present. Later, it is found that this method works well and is hereby recorded.

$(temp) .parent () .remove (); / / temp is the id of td.

My understanding is this: $(temp) first gets the td object, .parent () gets the tr of td, and then the remove () method deletes the tr.

Html Code:

123 456 aaa bbb

Js Code:

Function removeTr (temp) {$(temp) .parent () .parent () .remove () / / you must make sure that jQuery has been introduced, where $(temp) gets the object first, and then .parent () gets tr} Thank you for reading this article carefully. I hope the article "jquery how to remove tr" shared by the editor will be helpful to you. At the same time, I hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Tags: Methods articles code objects good value interest dynamics parameters and at the same time effects files more friends environment computers knowledge examples systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB MySQL Huawei Redmi