html()有三种使用方式
1 .html() 获取指定标签的内容,只取第一个
<body>
<p><font>fff</font></p>
<button id="btn1">获取值</button>
</body>
<script type="text/javascript">
$(function(){
$('#btn1').click(function(){
var htmlStr = $('p').html();
alert(htmlStr)
})
})
</script>
2 .html(Str) 给指定标签设置内容
<body>
<p><font>fff</font></p>
<button id="btn1">获取值</button>
</body>
<script type="text/javascript">
$(function(){
$('#btn1').click(function(){
$('p').html("*****");
})
})
</script>
3 . html(fun()) 接受函数返回值作为字符串, 和2相同,改变元素值
<body>
<p><font>fff</font></p>
<button id="btn1">获取值</button>
</body>
<script type="text/javascript">
$(function(){
$('#btn1').click(function(){
$('p').html(function(){
return "*****";
});
})
})
</script>
</html>