Home>Article>Web Front-end> How to remove tr in jquery
Jquery method to remove tr: 1. Create a js sample file; 2. Introduce jQuery; 3. Use the "function removeTr(temp){...}" method to remove tr.
The operating environment of this article: windows7 system, jquery-2.1.4 version, DELL G3 computer
How to remove tr from jquery?
jQuery remove tr
When I was working on a project today, I encountered a problem, which was to remove some tr (tr was added dynamically) . I have tried many methods, but none of them work (for example, in the deleteRow method, it seems that the parameter passed can only be the number of rows of tr. I have not studied it carefully so far). Later, I found that this method worked well, so I will record it here.
$(temp).parent().remove(); //temp为td的id。
My understanding is this: $(temp) first obtains the td object, .parent() obtains the tr of the td, and then remove() method to delete the tra8514cd333b622e555c6889e8a4a7671
html code:
123 | 456 |
aaa | bbb |
js code:
function removeTr(temp){ $(temp).parent().parent().remove(); //必须保证已经引入了jQuery,此处$(temp)先获取到对象,.parent()拿到,再.parent()获取到tr } Recommended learning: "jquery video tutorial"
The above is the detailed content of How to remove tr in jquery. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cnPrevious article:What are the options belonging to mouse event method in jquery Next article:What are the options belonging to mouse event method in jqueryRelated articles
See more