-1

I bound the blur function to a text box having class name 'qtyToPick'. Now I want to call the same blur function if I change checked property of a check box having class 'chkSelect'.

How can i do it ?

$('.qtyToPick').live('blur', function() {
 // Code here
});
SLaks
891k182 gold badges1.9k silver badges2k bronze badges
asked Mar 21, 2011 at 14:23
2
  • @SLaks. Was there any mistakes in my qustion ? Commented Mar 21, 2011 at 14:26
  • You should format code by indenting it with four spaces. Commented Mar 21, 2011 at 14:33

2 Answers 2

2

Define the function separately, and bind it to the appropriate events for the appropriate elements:

var theFunc = function() { /* Code here */ };
$( '.qtyToPick' ).live( 'blur', theFunc );
$( '.chkSelect' ).live( 'change', theFunc );
answered Mar 21, 2011 at 14:26
Sign up to request clarification or add additional context in comments.

2 Comments

$('#chkSelect').change(function() { $('.qtyToPick').blur(); });
I think trigger handler might be more appropriate in this case if you're taking that route.
0
$('#chkSelect').change(function() {
 $('.qtyToPick').blur();
});
answered Mar 22, 2011 at 5:06

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.