$("#id").append("哈哈哈")
$("#id").append("span哈哈哈")
var spanObj = document.createElement('span');
document.getElementById('xxxx').appendChild(spanObj);
样式什么的,自己写吧。
<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>