摘要:學(xué)完此個(gè)篇章,才發(fā)現(xiàn)用JQ操作屬性,也蠻方便的,掌握后能靈活運(yùn)用,能做不少事情<!doctype html><html> <head> <meta charset="gbk"> <title>JQ操作屬性作業(yè)</title> <script src=&qu
學(xué)完此個(gè)篇章,才發(fā)現(xiàn)用JQ操作屬性,也蠻方便的,掌握后能靈活運(yùn)用,能做不少事情
<!doctype html>
<html>
<head>
<meta charset="gbk">
<title>JQ操作屬性作業(yè)</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<style>
.box{background:#ccc;height:100px;width:100px}
.pox{background:red}
</style>
<script>
$('document').ready(function(){
$('div').addClass('box');
//$('div').removeClass('box');
$('.box2').css({"height":"100px","width":"100px","background":"red"});
//alert($('div').hasClass('box2'));
})</script>
<body>
<div></div>
<div></div>
<p>aaaaa</p>
<button onclick='to()'>按我變色</button>
</body>
<script>
function to(){
$('p').toggleClass('pox');
}
</script>
</html>