jquery – Only finding the next element – Education Career Blog

ok i have this jquery

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

I am using this plugin

I need to find the class element .band_notice that is in the form clicked

here is my 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>

For some reason my jquery is a bit off bit this seems like it should be right

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

,

Just take out the .parents() portion and use the fourth parameter for the form, like this:

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

From the docs, here are the parameters for your success method:

  1. responseText or responseXML value (depending on the value of the dataType option).
  2. statusText
  3. xhr (or the jQuery-wrapped form element if using jQuery < 1.4)
  4. jQuery-wrapped form element (or undefined if using jQuery < 1.4)

Leave a Comment