只找到下一个元素

时间:2010-10-21 02:08:22

标签: jquery

好的,我有这个jquery

    $('.make_request').ajaxForm(function() { 
// $('.band_notice').show();
$(this).parents('.accordionContent').find('.band_notice').show();
        }); 

我正在使用此plugin

我需要找到点击

形式的类元素.band_notice

这是我的HTML

    <div class="accordionContent">
<form action="/make_requests" class="make_request" method="post"><div style="margin:0;padding:0;display:inline"></div>                                                      .......
            .......
    </tr>
    <tr><td><input id="make_requests" name="commit" type="submit" value="Add to Set" /></td><td><span class="band_notice">Set Added</span></td></tr>
                  </form>


    <div class="accordionContent">
<form action="/make_requests" class="make_request" method="post"><div style="margin:0;padding:0;display:inline"></div>                                                      .......
            .......
    </tr>
    <tr><td><input id="make_requests" name="commit" type="submit" value="Add to Set" /></td><td><span class="band_notice">Set Added</span></td></tr>
                  </form>

出于某种原因,我的jquery有点偏离这看起来应该是正确的

$(this).parents('.accordionContent').find('.band_notice').show();

1 个答案:

答案 0 :(得分:1)

只需取出.parents()部分并使用表单的第四个参数,如下所示:

$('.make_request').ajaxForm(function(response, status, xhr, form) { 
  form.find('.band_notice').show();
});

From the docs,以下是success方法的参数:

  1. responseText或responseXML值(取决于dataType选项的值)。
  2. 状态文本
  3. xhr(或jQuery包装的表单元素,如果使用jQuery&lt; 1.4)
  4. jQuery包装的表单元素(如果使用jQuery&lt; 1.4,则为undefined)
相关问题