저는 Ajax에서 사용하려는 div의 내용을 js로 변경하려고합니다. Firefox 스크래치 패드를 사용하여이 함수를 디버깅했습니다.js에서 create 속성을 사용하면 'not a function'이 발생합니다.
function show(id){
var div = document.getElementById('com');
div.innerHTML = '';
var input1 = document.createElement('input')
.createAttribute('type').setAttribute('type', 'hidden')
.createAttribute('value').setAttribute('value',id)
.setAttribute('name','id');
var input2 = document.createElement('input')
.createAttribute('type').setAttribute('type', 'input')
.createAttribute('name').setAttribute('name', 'com');
var btn = document.createElement('button')
.createAttribute('onClick').setAttribute('onClick', 'post()');
btn.innerHTML = 'Comment';
div.appendChild(input1).appendChild(input2).appendChild(btn);
}
어떤 내가 가진 것은 이것이다 :
/*
Exception: document.createElement(...).createAttribute is not a function
@Scratchpad/2:2
*/
내가 아무것도 이해하지, 어떤 아이디어?