【问题标题】:Jquery Hide/show using dropdown options not working IE or CHROMEJquery 使用下拉选项隐藏/显示不起作用 IE 或 CHROME
【发布时间】:2010-09-27 19:22:23
【问题描述】:

我有多个下拉菜单用于隐藏/显示表格中的行。

例子:

 <select name="kp1_action" class="longboxsmall">
     <option class="hidenextrow" value="">Button Disabled</option>
    <option class="showtransferoptions" value="transfercall">Transfer Call + Log Keypress to Reports</option>
    <option  class="shownextrow" value="logkeypress">Log Keypress to Reports Only</option>
    <option  class="shownextrow" value="optout">Optout of Call List</option>
  </select>

我已经为每个不同的选项分配了类,因此我可以在单击它们时触发事件,这是我的 jQUERY。

        $(".shownextrow").click(function() { 
  $(this).closest("tr").next().show().find('.longboxsmall').hide();
});

                        $(".showtransferoptions").click(function() { 
  $(this).closest("tr").next().show().find('.longboxsmall').show();
});



                $(".hidenextrow").click(function() { 
  $(this).closest("tr").next().hide().find('.longboxsmall').hide();
});

在 Firefox 中一切正常,但在 IE 或 CHROME 中却不行,这是为什么?有没有更好的方法来完成上述操作?

【问题讨论】:

    标签: jquery drop-down-menu html-table cross-browser show-hide


    【解决方案1】:

    我会将“更改”事件绑定到 SELECT,然后在事件处理程序中评估 SELECT 的值。

    $("SELECT[name=kp1_action]").change(function()
    {
        if(this.value == "transfercall") {
            ...
        }
        // OR
        if($(this).hasClass("shownextrow")) {
            ...
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2012-04-20
      • 2015-05-13
      • 2012-09-25
      • 2012-09-28
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 2014-10-24
      • 2013-09-16
      相关资源
      最近更新 更多