JQ操作属性作业

Original 2019-01-02 14:16:58 264
abstract:学完此个篇章,才发现用JQ操作属性,也蛮方便的,掌握后能灵活运用,能做不少事情<!doctype html><html> <head>  <meta charset="gbk">  <title>JQ操作属性作业</title>  <script src=&qu

学完此个篇章,才发现用JQ操作属性,也蛮方便的,掌握后能灵活运用,能做不少事情
<!doctype html>

<html>

 <head>

  <meta charset="gbk">

  <title>JQ操作属性作业</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>


Release Notes

Popular Entries