私は js を使用して、コンテンツ入力の div のコンテンツを変更しています。 Ajax でそれらを使用したいのですが、Firefox スクラッチパッドを使用してこの関数をデバッグしました:
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
*/
私は何も理解していませんでした。何かアイデアはありますか?