举个例子:
html代码:<p>I would like to say: </p>
jquery 代码: $("p").append("<b>Hello</b>")
结果:<p>I would like to say: <b>Hello</b></p>
利用jq的append()追加函数即可实现,如:
html:
<div class="main"><input type="button" value="添加" class="btn" />
</div>
JQ:
$(document).ready(function(){$(".btn").click(function(){
var html = '<div style="width:200px height:30px border:1px dashed red margin-bottom:20px"></div>'
$(".main").append(html)
})
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)