jquery改变样式

作者:流年 | 创建时间: 2023-07-29
点击div时会调用jquery事件从而改变样式...
jquery改变样式

操作方法

创建两个样式 <style type="text/css">.style1{width: 80px;height: 100px;margin: 0px auto;margin-bottom:20px;border:1px solid #96C2F1;background-color: #EFF7FF}.style2{width: 80px;height: 100px;margin: 0px auto;margin-bottom:20px;border:1px solid #9BDF70;background-color: #F0FBEB}</style>

创建改变事件 <script>$(document).ready(function(){  $("div").click(function(){    $(this).attr("class","style2");  });});</script>

创建div <div class="style1"></div>

点击div任何区域就会改变样式为style2

点击展开全文

更多推荐