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 );
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 el
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 submi
Sweet thanks! That's pretty neat how you can wrap it again in
jquery ...
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
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
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 P
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/Even
7 matches
Mail list logo