jQuery设置\获取元素内容
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jquery第九节课</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(function(){
//jQuery获取\设置内容
//text()设置或返回所选元素的文本内容;
console.log($('p').text())
// $('p').mouseover(function(){
// $(this).text('~ 我是灭绝小师太! ~')
// })
//html()设置或返回所选元素的内容(包括 HTML 标记)
console.log($('p').html())
//val()设置或返回表单字段的值;
console.log($('input').val())
$('input').click(function(){
$(this).val('请请输入关键词....')
})
})
</script>
<style type="text/css">
*{margin:0;padding:0;}
p{width:300px;height:300px;line-height: 300px;background:#9BF25A;margin:20px auto;text-align: center;}
form{width: 450px;margin: 20px auto;}
input{width: 450px;height: 35px;}
</style>
</head>
<body>
<p>
欢迎来到<a href="">0133技术站!</a>
</p>
<form>
<input type="text" value="你好">
</form>
</body>
</html>