input输入内容回车生成标签代码
在input文本框中输入标签内容后,回车创建标准效果。
<style> #tag a{margin-right:10px;color:blue;border:dotted 1px blue;cursor:pointer}</style> <span id="tag"></span><input type="text" onkeydown="addTag(event,this)" /> <script type="text/javascript"> function addTag(e, o) { if (e.keyCode == 13 && o.value != '') { var a = document.createElement('a'); a.innerHTML = o.value + ' x'; a.onclick = function () { this.onclick = null; document.getElementById('tag').removeChild(this); }; document.getElementById('tag').appendChild(a); o.value = ''; return false; } } </script>
加支付宝好友偷能量挖...
原创文章,转载请注明出处:input输入内容回车生成标签代码