Posted on 2009/02/18 10:05 | CodeIN/Web



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):


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");');

DOM Table로 dynami 테이블을 생성할 때 event를 추가하는 방법이다.
 
트랙백 주소 :: http://www.voiceportal.co.kr/528/trackback/
profile image

To be able to do what you want is the freedom, to enjoy what you do is the happiness.

옵션
댓글 달기

블로그 이미지
Blog Image
김태정, All on Voiceportal

Voice portal에 대한 정보 공유.

by 김태정
프로필 버튼
프로필 상세보기
블로그롤 정보

Calendar*
«   2010/03   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Comment*
Counter*
Total
554903
Today
268
Yesterday
1203