批改状态:合格
老师批语:
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<div class="box">
<img src="./images/1.jpg" width="200" alt="美女" title="明星" id="pic" data-nation="中国">
</div>
</body>
<script type="text/javascript">
// 当传递两个参数的时候是设置他的属性
// 当传递一个参数的时候是读取他的属性
// var res=$('img').attr("src")
$('img').attr("height","180px")
// 设置自定义属性然后变动覆值,不能删除原声属性
$('img').prop('data-nation','中国山东')
var res = $('img').prop('data-nation')
$('img').addClass('')
var res = $('img').css({
'width': '200',
'border-radius': '10%',
'box-shadow': '3px 3px 3px #888'
})
console.log(res)
</script>
</html>点击 "运行实例" 按钮查看在线实例
结果

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号