Issue
I have a table in html. And I am having click event on each row of that table. I have 4 items on each row and the last item in dropdown. I want to prevent row click when I click on drop down item and vice versa.
<tr onclick="doSomething()">
<td>text</td>
<td>text</td>
<td>text</td>
<td onclick="doSomethingElse()">
<!-- drop down elements -->
</td>
</tr>
I know something about preventDefault(); but don't know how to use that here.
Solution
preventDefault is not needed here. You can easily achieve it using stopPropogation()
<tr onclick="doSomething()">
<td>text</td>
<td>text</td>
<td>text</td>
<td onclick="doSomethingElse(); event.stopPropagation(); ">
<!-- drop down elements -->
</td>
</tr>
Hope it helps.
Answered By - Chirag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.