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} |