Fred J. Fred J. - 7 months ago 64
jQuery Question

combining jQuery selectors

My IDE is complaining about in-efficient use of jQuery selector and I am wondering if there is a better way to do this. Thanks

$('#login2>input').attr("disabled", 'true');


Assign $('#login2') to var:

var $login = $('#login2');

$login.find('input').prop('disabled', true);

Should also be able to chain, but (to me) can get messy:

$login.addClass('inactive').find('input').prop('disabled', true);