如何将4个按钮和面板组合到jQuery命令中 [英] How do I combine 4 buttons and panels into jQuery command
本文介绍了如何将4个按钮和面板组合到jQuery命令中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我输入这个jQuery代码而没有任何按钮切换各自的面板。
I enter this jQuery code and none of the buttons Toggle their respective Panels.
<script type="text/javascript" src="C://Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$(".panel-btn").on('click', function () {
var panelID = $(this).attr("data-panelid");
$('#' + panelID).fadeToggle(200);
});
});
</script>
...
...
<input type="button" id="Button5" class="panel-btn" data-panelid="Panel5" runat="server" value="Button5" />
<input type="button" id="Button6" class="panel-btn" data-panelid="Panel6" runat="server" value="Button6" />
<input type="button" id="Button7" class="panel-btn" data-panelid="Panel7" runat="server" value="Button7" />
<input type="button" id="Button8" class="panel-btn" data-panelid="Panel8" runat="server" value="Button8" /><br /><br />
<asp:Panel ID="Panel5" style="display:none" runat="server">123</asp:Panel>
<asp:Panel ID="Panel6" style="display:none" runat="server">456</asp:Panel>
<asp:Panel ID="Panel7" style="display:none" runat="server">789</asp:Panel>
<asp:Panel ID="Panel8" style="display:none" runat="server">000</asp:Panel>
推荐答案
( f unction (){
( 。panel-btn )。on(' 点击',函数(){
var panelID =
(".panel-btn").on('click', function () { var panelID =
( this )。attr( data-panelid);
(this).attr("data-panelid");
这篇关于如何将4个按钮和面板组合到jQuery命令中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文