<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
width: 100px;
height: 100px;
border: 1px solid #000;
}
</style>
</head>
<body>
<script src="jquery-1.10.1.min.js"></script>
<script>
$(function()
{
var btns=document.getElementsByTagName('button');
btns[0].onclick=function()
{
$("div").html("<p>我是段落<span>cyg</span></p>");
}
btns[1].onclick=function()
{
console.log($("div").html());
}
btns[2].onclick=function()
{
$("div").text("<p>我是段落<span>cyg</span></p>");
}
btns[3].onclick=function()
{
console.log($("div").text());
}
btns[4].onclick=function()
{
$("div").val("<p>我是段落<span>cyg</span></p>");
}
btns[5].onclick=function()
{
console.log($("div").val());
}
})
</script>
<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>