Hi Hector that worked awesome. For anyone that comes across this in a search here's the final code with the FORMS plugin:
$("#question input[type=submit]").click( function(event) { var element = ( event.target ? event.target : event.srcElement ); $('#question').ajaxSubmit({ success: function(t) { if( $(element).attr("id") == 'nextSubmit' ) { url = document.getElementById( 'nextUrl' ).value; } if( $(element).attr("id") == 'prevSubmit' ) { url = document.getElementById( 'prevUlr' ).value; } window.location.href = url; } }); return false; } ); On Nov 18, 1:14 pm, "Hector Virgen" <[EMAIL PROTECTED]> wrote: > My bad, it turns out what is happening is that the submit event is fired on > the form *after* the click event fires for the submit button. That's why > event.target == the form. > This should work, but it only works for submit buttons: > > $('#theForm input[type=submit]').click(function(event) > { > var element = event.target; > alert($(element).attr('id')); > return false; > > }); > > -Hector > > On Tue, Nov 18, 2008 at 1:05 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > > Hey hector, first off thanks for all your help. > > > So I have the following: > > > $("#form").submit( function(event) { > > var element = event.target; > > > alert( $(element).attr("id") ); > > > return false; > > } > > ); > > > I get "form" back instead of the id of my submit button ... thoughts > > on what I'm doing wrong? > > > MS > > On Nov 18, 12:06 pm, "Hector Virgen" <[EMAIL PROTECTED]> wrote: > > > event.target returns a native dom element. You can then wrap that element > > > with $() to use all of jQuery's methods. > > > var element = event.target; > > > $(element).attr('id'); // returns the id of the element > > > element.getAttribute('id'); // also returns the id in native javascript, > > but > > > does not work in IE (of course...) > > > > I hope this helps! :) > > > > -Hector > > > > On Tue, Nov 18, 2008 at 11:51 AM, Mark Steudel <[EMAIL PROTECTED]> > > wrote: > > > > > Thanks that worked great. I don't have much experience working with > > > > events, and I'm having troubles finding out how to access various > > > > properties of the event.target, do you have suggestions/links? I guess > > > > I'd like to know the id and the name, thanks! > > > > > On Nov 18, 10:53 am, "Hector Virgen" <[EMAIL PROTECTED]> wrote: > > > > > An event object is always passed as the first argument to the > > function, > > > > > which contains the information you need. > > > > > $('#form').submit(function(event) > > > > > { > > > > > // Get the element that fired the event > > > > > var element = event.target; > > > > > > }); > > > > > > For more info check out the Events guide: > > > >http://docs.jquery.com/Events_(Guide) > > > > > > -Hector > > > > > > On Tue, Nov 18, 2008 at 10:47 AM, Mark Steudel <[EMAIL PROTECTED]> > > > > wrote: > > > > > > > Hi I have a form that has two submit buttons I am utilizing the > > > > > > following ajaxSubmit code: > > > > > > > $("#form").submit( function() { > > > > > > $(this).ajaxSubmit({ > > > > > > target: '#response' > > > > > > }); > > > > > > > return false; > > > > > > } > > > > > > ); > > > > > > > Inside the submit function is there a way to figure out which > > button > > > > > > was clicked? I tried doing something like > > > > > > > $(this).attr("id") > > > > > > > but it gives the id of the form, not the button .... > > > > > > > TIA