jQuery文本相关操作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery-3.3.1.min.js"></script>
<title>Document</title>
<style>
div{
height: 100px;
width: 100px;
border: 1px solid red;
}
</style>
<script>
$(function(){
var btu = document.getElementsByTagName("button");
btu[0].onclick= function(){
$('div').html("<span>呵呵呵</span>")
};
btu[1].onclick = function(){
console.log($('div').html())
}
btu[2].onclick= function(){
$('div').text("<span>哈哈哈</span>")
};
btu[3].onclick = function(){
console.log($('div').text())
}
btu[4].onclick= function(){
$('input').val("<span>嘻嘻</span>")
};
btu[5].onclick = function(){
console.log($('input').val())
}
})
</script>
</head>
<body>
<button>设置html</button>
<button>获取html</button>
<button>设置text</button>
<button>获取text</button>
<button>设置value</button>
<button>获取value</button>
<div></div>
<input type="text">
</body>
</html>