P
Prince of Code
Hey all,
I m trying to add onClick() event dynamically using DOM Method . But
why the event is not able to be triggered. Also I dont see it in the
DOM Source. Pls find the code for refrence.
Your explanation would be greatly useful.
Thanks
Prince
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Sample Page </TITLE>
</HEAD>
<BODY>
</BODY>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function hellofn()
{
alert("Hello World !");
}
atag = document.createElement("a");
atag.innerHTML = "click this link";
// Why is the I am not able to call the onclick event
handler ??????????????
atag.onClick="hellofn();"
atag.href = "#";
document.body.appendChild(atag);
</SCRIPT>
</HTML>
I m trying to add onClick() event dynamically using DOM Method . But
why the event is not able to be triggered. Also I dont see it in the
DOM Source. Pls find the code for refrence.
Your explanation would be greatly useful.
Thanks
Prince
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Sample Page </TITLE>
</HEAD>
<BODY>
</BODY>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function hellofn()
{
alert("Hello World !");
}
atag = document.createElement("a");
atag.innerHTML = "click this link";
// Why is the I am not able to call the onclick event
handler ??????????????
atag.onClick="hellofn();"
atag.href = "#";
document.body.appendChild(atag);
</SCRIPT>
</HTML>