Setting onclick() in DOM using Javascript. - DOM Views : 1131
Tagged in : DOM
0 0
Send mail
Setting onclick() in DOM using Javascript.
Using javascript setAttribute(), eventlisteners like onmouseover,onclick in DOM won't work in IE.

hence instead of using,
yy.setAttribute("onclick","somefunction()");
use,
yy.onclick = function() {Javascript: somefunction();};

If you want to display the value of the attribute(ie.value maybe some event) and if you pass the attribute to a function where the event is displayed as,
yy.onclick = function() {Javascript: somefunction('tt');};
it will result as [objectHTML]

To get the value of an attribute using onclick() in DOM,
set the attribute as,
var x = tt.value;




By Ramya, On - 2008-05-15



    Login to add Comments .