2010-10-21 518 views
0

好吧,我有這個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

剛取出.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 < 1.4)
  4. jQuery的包裹的形式元件(或未定義如果使用jQuery < 1.4)
+0

,實際上沒有工作.. 。不知道爲什麼不......這個插件可能會改變這個 – Trace 2010-10-21 02:12:53

+0

我做了console.log(這個)並得到了Object {url =「/ make_requests」,更多...} – Trace 2010-10-21 02:14:06

+0

@Matt - 啊,一秒鐘,檢查參數 – 2010-10-21 02:14:33