点击显示当前class

来源:互联网 发布:美国ela数据 编辑:程序博客网 时间:2024/05/16 12:22
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script><style type="text/css">.d1{border-radius:50%;}</style></head><body><div id="btn1"><div class="d1" style="width:100px;height:100px;background:#0f0"></div><div style="width:100px;height:100px;background:#00f"></div><div style="width:100px;height:100px;background:#f00"></div></div><script type="text/javascript">$("#btn1").on("click","div",function(){$(this).siblings().removeClass();$(this).addClass("d1");});</script></body></html>

0 0
原创粉丝点击