Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does jquery get rid of tr

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report