|
|
Setting onclick() in DOM using Javascript. - DOM
|
Views : 1131
|
|
Tagged in : DOM
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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 |
|
|
|