It doesn't, because the
onclick property of your HTMLElement object is
called as a method, and you've set it to a string value:
element.onclick = 'alert("something")'; // doesn't work
Your options include (but are not limited to):
called as a method, and you've set it to a string value:
element.onclick = 'alert("something")'; // doesn't work
Your options include (but are not limited to):
1. element.setAttribute('onclick', 'alert("hi")');
2. function elClick() { alert('hi'); } // create a function object - put
this in your global scope to avoid closure memory leaks
....
// elsewhere...
element.onclick = elClick;
3.
element.onclick = new Function('alert("hi");');
2. function elClick() { alert('hi'); } // create a function object - put
this in your global scope to avoid closure memory leaks
....
// elsewhere...
element.onclick = elClick;
3.
element.onclick = new Function('alert("hi");');
DOM Table로 dynami 테이블을 생성할 때 event를 추가하는 방법이다.








