I’m catching data-async of form created using twitter bootstrap in following manner:
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
var target_id = $target[0].id;
....
}
I’d like to reference input with name “username” in the form in question… I tried $form.username, $form[‘username’], but to no avail, and I couldn’t find how to get the input. I know I can use
$('#formid input[name=bla]')
but since I’ve already got form object, I’d like to use that if possible.
Thanks
Inside your submit handler, the
usernameinput field can be referenced simply by:No need for fancy jQuery 🙂
Update
Didn’t realize
elementsis a fairly recent addition. Before that you could use:Update 2
A shimmed version would look like this: