Thursday, 12 September 2013

Change the OnClick event using javscript

Change the OnClick event using javscript

I am having an html anchor tag like
<a href="anchorid" onclick="callEvent(1)">
Here it call the Javascript function like
<script>
function callEvent(anchor) {
alert("Anchor ID is - "+anchor);
document.getElementById("anchorid").onClick = function () {
callEvent(0) }; // BY using this code, update the onclick
callEvent(0), like toggle
}
</script>
I wants to update the anchor tag like
<a href="anchorid" onclick="callEvent(0)">
by using this code, it is not updating as per my requirement..
document.getElementById("anchorid").onClick = function () { callEvent(0) };
Plz help me..

No comments:

Post a Comment