0

我正在尝试选择与更改的输入标签最接近的 div。当我运行它时,什么也没有发生。我已经尝试了最近的标签和下一个标签。

$("input[id='declined']").change(function(){
     $(this).next('div.textarea_container').fadeIn();
});

html:

    <div id="gcheckbox">
         <input type="radio" id="name10" class="guidelines" name="Confirmed diagnosis of melanoma" value="Accepted">
         <input type="radio" class="guidelines no_margin" name="Confirmed diagnosis of melanoma" id="declined" value="Declined">
         <label>Confirmed diagnosis of melanoma</label>
              <div class="textarea_container">
                 <textarea placeholder="reason" id="notearea0"></textarea>
              </div>
     </div>

我现在制作了一个示例文件。 http://jsfiddle.net/dMmuW/

4

1 回答 1

2

jQuery 的next功能只适用于相邻的兄弟元素,用于nextAll获取所选元素之后的所有兄弟元素并过滤到您想要的元素。

$('#declined').change(function () {
    $(this).nextAll('div.textarea_container').fadeIn();
});
于 2013-04-30T00:07:29.617 回答