restrict event propagation in javascript

<tr id=”my_tr” onclick=”javascript:my_tr_click();”>
<td>
<a id=”my_atag” href=”javascript:void(0);” onclick=”javascript:var event = arguments[0] || window.event; my_a_click(event);”>Delete</a>
<td>
</tr>

<script>
function my_tr_click() {
alert(‘tr click’);
}

function my_a_click(e) {
alert(‘td a click’);
e.cancelBubble = true;
if (e.stopPropagation)
e.stopPropagation();
}
</script>

About selvam4win

I am Selvam. I am very jolly person and frank one.

Posted on February 4, 2013, in javascript and tagged , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: