返回JQ操作属性作......登陆

JQ操作属性作业

末幽客2019-01-02 14:16:58264

学完此个篇章,才发现用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>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送