javascript - Jquery特选

标签 javascript jquery jquery-ui

我有以下 html 代码:

<div class="Radios">
     <span class="radio">
          <input type="radio" value="1"> yes
          <input type="radio" value="0"> no
     </span>
</div>
<div class="More">hello</div>
<div class="More">hello</div>

<div class="Radios">
     <span class="radio">
          <input type="radio" value="1"> yes
          <input type="radio" value="0"> no
     </span>
</div>
<div class="More">hello</div>

<div class="Radios">
     <span class="radio">
          <input type="radio" value="1"> yes
          <input type="radio" value="0"> no
     </span>
</div>
<div class="More">hello</div>
<div class="More">hello</div>
<div class="More">hello</div>

默认情况下,所有带有 class=more 的 div 都应该被隐藏。我使用 $('div.More').hide()

困难的是,当用户单击值为“1”的单选按钮时,应显示所有 div.Radios 的下一个同级 div.Radios(但仅显示中间同级,而不是所有 div.More)。

到目前为止,我单击了一个元素的父元素,但无法选择下一个 div。更多元素,直到下一个 div.Radios。

你能帮我一下吗?

致以诚挚的问候。

何塞

最佳答案

but i cannot select the next div.More elements until the next div.Radios.

使用nextUntil() :

$('input[type=radio][value=1]').click(function () {
    $(this).parents('.Radios').nextUntil('.Radios').show();
}

关于javascript - Jquery特选,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3083578/

相关文章:

javascript - 在客户端使用PHP或JavaScript通过大量关键词逐一搜索大量数据

javascript - 网格和动态表的高度

jquery - 在 jquery 中触发多个第 n 个子项的悬停状态的最有效方法

jquery ui 可拖动约束 ina 轴 x 和给定坐标

javascript - 单击标题时 jQuery 对话框 UI 关闭

javascript - 在没有 jquery 的情况下在 javascript 中添加和删除类

javascript - Coffeescript:使用 coffeescript 的 moment js 动态更新时间

JQuery UI 按钮图标不显示

javascript - 数据表:How to control the <th> width of table .我正在使用Jquery -1.9.4版本

javascript - 向下滚动时的 jQuery 对话框位置