Select submit button of specific form for click event

javascript, jquery

Solution

This will automatically select the form's submit control:

$('#login :submit').click(...);

http://api.jquery.com/submit-selector/

Cheers

Problem

If I have the following form, how can I select the submit button based on the form ID to be used for a click event? ``` <form id="login"> <input type="text" name="email"> <input type="text" name="password"> <input type="submit" name="submit"> </form> ``` Something like the following works, but it can't just be `input[name=submit]` because there may be more than one on the page. ``` $('input[name=submit]').click(function (e) { e.preventDefault(); console.log('clicked'); }); ```

Original source