<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery操作属性的方法</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
.box{color: red;}
.main{font-size: 40px;font-weight: bold;}
.aa{ list-style:none;background: pink;height: 30px;width: 400px; }
.bb{color: blue;}
</style>
</head>
<body>
<img src="images/1.jpg">
<button>点击删除图片</button>
<div class="one">你好</div>
<script type="text/javascript">
$(document).ready(function(){
$('p').addClass('box main')
$('p').removeClass('main')
alert($('p').attr('title'))
$('p').attr('title','你好')
alert($('p').attr('title'))
$('button').click(function(){
$('img').removeAttr('src')
})
$('button').click(function(){
alert($('div').hasClass('one'))
})
})
$(document).ready(function(){
$('button').click(function(){
$('span').toggleClass('bb')
})
alert($('b').text())
$('span').text('对影成三人')
$('b').text('孤蓬万里征')
alert($('p').html())
$('p').html('<h3>此情无计可消除</h3>')
alert($('input').val())
$('input').val('诗成泣鬼神')
})
</script>
<span>举杯邀明月</span><br>
<b>此地一为别</b>
<p title="jQuery">php中文网</p>
<input type="text" name="" value="笔落惊风雨">
</body>
</html>