나는 TD
자바 스크립트 부착 클릭 이벤트 문제
내부 <a>
태그 설정에 click
이벤트를 시도하고 나는
test.prototype.buildData = function() {
cell = createElement('td', {innerHTML: "<a class='link' onclick='"+this.edit(this)+"'>"+ value + "</a>"});
this.table.appendChild(cell);
//many cells..all need to attached the click event
}
test.prototype.edit=function(this){
this.style.backgroundColor='red'
}
내가 클릭 cell
background color
을 수정할 수 있습니다. 태그에만 click
이벤트를 등록해야합니다. 내 this.edit(this)
은 이해가되지 않습니다.
어쨌든 이것을 할 수 있습니까? 고마워요!
먼저 ... onclick을 사용하지 마십시오. – natlee75