可以事先写一个输入框,默认是隐藏的,当你单击的时候直接让它显示。
<!-- HTML --><div>
<span onclick='reply()'>回复我!</span>
<input style='display: none' id='reply' />
</div> // JavaScript
function reply() {
document.getElementById('reply').style.display = 'block'
}
document.txt.innerHTML+='<p><input type="text" name="text[]" />
<input type="text" name="text[]" />
<input type="text" name="text[]" />
<input type="text" name="text[]" />
</p>'
替换成
document.body.innerHTML +='<p><input type="text" name="text[]" /><input type="text" name="text[]" /><input type="text" name="text[]" /><input type="text" name="text[]" /></p>'
以jquery为例
<input class="ck" data="1"><input class="ck" data="2">
<input class="ck" data="3">
var html
$( ".ck" ).click( function() {
if( this.checked ) {
html = '<input type="text" value="' + $( this ).attr( "data" ) + '">'
$( "body" ).append( html )
}
} )
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)