i have wrote an onclick event for the rows of the table (<tr> tag) but i want to disable the onclick for two columns (<td> tag). what should i do?
by defualt when i enable onclick for a row it will works for all the column in the row.
my row has 12 columns and i don't need onlick for the last twos. one solution is that i repeat the same code for 10 columns instead of the row but it is not a good approach. i think there should be some event arguments like c++ and C# that can reveal which cell has been clicked and if it was a special one then the code can cancel onclick event. i appriciate any help...
canceling onclick event for some cells in the table
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: canceling onclick event for some cells in the table
you want to stop the event from "bubbling" or "propagating", depending on who makes the browser.
here's a little cross-browser script (from PPK) that should help:
here's a little cross-browser script (from PPK) that should help:
Code: Select all
function stopProp (e) {
var evt = e || window.event;
if (evt.stopPropagation)
evt.stopPropagation();
evt.cancelBubble = true;
}
Re: canceling onclick event for some cells in the table
i want stop the event from bubbling...also where in the code should i call the function that you have proposed?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: canceling onclick event for some cells in the table
The event handler for the td cells.
Actually, repeating things for the 10 columns isn't too far-fetched if you use JavaScript to set the event handlers.
Actually, repeating things for the 10 columns isn't too far-fetched if you use JavaScript to set the event handlers.
Re: canceling onclick event for some cells in the table
i think Kieran Huggins's answer is near to what i want to do but somewhat i need more explanation.
Re: canceling onclick event for some cells in the table
Check http://www.quirksmode.org/js/introevents.html ,good explanation for it.