Delete current row

M

marty.weel

I have the following...

<table>
<tr>
<td>
Test
</td>
<td>
<a href='NEEDCOEHERE'>delete row</a>
</td>
</tr>
</table>

How could I delete the current row that the href is a part of? I would
like to try to stay away from using IDs.

Thanks in advance,

Mardo
 
J

Jonas Raoni

I have the following...

<table>
<tr>
<td>
Test
</td>
<td>
<a href='NEEDCOEHERE'>delete row</a>

You don't need code here, leave the href with a real url ;]

And add the JavaScript behaviou using DOM and the so-called addEvent.

</td>
</tr>
</table>

How could I delete the current row that the href is a part of? I would
like to try to stay away from using IDs.

Well, if you're inside the "<a>", you just need to go up into the node
chain and remove the first <tr> that you find ;]

Something like this:

for(var x = YourCurrentNode, r = /^tr$/i; !r.test(x.nodeName) &&
x.parentNode; x = x.parentNode);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top