8.jquery操作标签内容
作者:互联网
<head>
<meta charset="UTF-8">
<title>2.操作标签内容</title>
</head>
<body>
<div class="no1">
<span style="color: fuchsia">今晚打老虎</span>
</div>
<hr>
<div class="btn">
<input type="button" value="显示innerHtml">
<input type="button" value="更改innerHtml">
<input type="button" value="获取Text">
<input type="button" value="更改innerHtml2">
</div>
<hr>
<div id="show"></div>
</body>
<script src="js/jquery-1.8.3.js"></script>
<script>
/*显示标签内容*/
$(".btn :button :eq(0)").on("click",function () {
$("#show").html($(".no1 span:first").html());
})
$(".btn :button :eq(1)").on("click",function () {
$(".no1 span:first").html("老虎没打着");
})
/*获取text*/
$(".btn :button :eq(2)").on("click",function () {
$("#show").html($(".no1 span:first").text());
})
$(".btn :button :eq(3)").on("click",function () {
$(".no1 span:first").html("<input type='text' value='想不到吧'>")
})
</script>
标签:jquery,function,span,标签,button,html,操作,btn,no1 来源: https://www.cnblogs.com/wgbl/p/16154477.html