【问题标题】:IE not getting the right next elementIE 没有得到正确的下一个元素
【发布时间】:2013-01-15 16:04:11
【问题描述】:

假设我点击<div class="span10 -configGroup-title" >

在 IE 中,$(this).parent().next().next() 取回 <img alt="arrow" src="../arrow_normal.png" class="-arrow" />

在 Chrome 中,它获取 <div id="seconddiv"/>

 <div class="row">
     <div class="span10 -configGroup-title" >
          <img alt="arrow" src="../arrow_normal.png" class="-arrow" />
          <img alt="arrow" src="../arrow_down.png" class="-arrow" style="display: none;" />
          <asp:Literal ID="ltGroupAttrName" runat="server" />
     </div>  
 </div>  
 <asp:ListView ID="lvProperties" runat="server" EnableViewState="true"  />
<div id="seconddiv"/>

【问题讨论】:

  • 请包含所有相关代码 - 您的示例没有 li#second 元素。
  • 这与标记有关,而不是 jQuery。
  • $(this) 引用&lt;div class="span10 ..."&gt; 的上下文是什么?
  • 什么是&lt;div id="seconddiv"&gt;?它没有显示在您的代码中

标签: jquery html cross-browser


【解决方案1】:

我想正在发生的事情(尽管我无法确定没有看到完整的代码并能够对其进行测试)是您实际上点击了&lt;div class="span10 -configGroup-title"&gt; 的一个孩子当您尝试单击div 本身时(这是有道理的,因为两个img 标签将处于比div 更高的拓扑级别)。

您可以尝试通过插入一些代码来显示$(this) 的标识属性来调试它。这可能会说明你正在发生什么。

【讨论】:

  • 我实际上是在点击
    本身.. 我不明白的是......在 IE 中 parent().next().next() .toggle() 正在切换 ... 我想要
    像在 chrome、opera、firefox 中一样被调用
  • 不,我明白你想要什么。但是如何你知道你点击的是实际的DIV
【解决方案2】:

试试这个:

$(this).parent(".row").siblings("#seconddiv");

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签