大佬教程收集整理的这篇文章主要介绍了使用JQuery更轻松地隐藏/显示div,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
$(".btn").click(function (){ $(".Hide").hide("fast"); }); $("#btn_one").click(function () { $("#one").show("fast"); }); $("#btn_two").click(function () { $("#two").show("fast"); }); $("#btn_three").click(function () { $("#three").show("fast"); });
HTML:
<a href="#" id="btn_one" class="btn">one</a> <a href="#" id="btn_two" class="btn">one</a> <a href="#" id="btn_three" class="btn">one</a> <div id="one" class="Hide">1</div> <div id="two" class="Hide">2</div> <div id="three" class="Hide">3</div>
$(".btn").click(function () { $(".Hide").hide("fast"); $("#" + $(this).data('type')).show("fast"); });
HTML:
<a href="#" id="btn_one" data-type="one" class="btn">one</a> <a href="#" id="btn_two" data-type="two" class="btn">one</a> <a href="#" id="btn_three" data-type="three" class="btn">one</a>
您可以使用data-something来引用相应的元素.
以上是大佬教程为你收集整理的使用JQuery更轻松地隐藏/显示div全部内容,希望文章能够帮你解决使用JQuery更轻松地隐藏/显示div所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。