jquery实现同样效果
有没有用jquery写的?求指教,谢谢大家
有没有用jquery写的?求指教,谢谢大家
2017-05-29
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> $(window).ready(function() { var listBtn = $("#btn1"),cardBtn = $("#btn2"),imgs = $("img"); listBtn.click(function() { listBtn.attr("class","btn-list-on"); cardBtn.attr("class","btn-car-off"); imgs.attr("src","http://img1.sycdn.imooc.com//53ab7cf4000196c000500050.jpg"); imgs.parent().addClass("small"); }); cardBtn.click(function() { listBtn.attr("class","btn-list-off"); cardBtn.attr("class","btn-car-on"); imgs.attr("src","http://img1.sycdn.imooc.com//53ab7d16000159a801640236.jpg"); imgs.parent().removeClass("small"); }); }); </script>
路径或者类名啥的自己改改就行了,放在head里面不用讲了吧
举报