I've certain number of Input elements inside a div. When any of the input element inside the div gets focus I want disable an element outside the div? How can do this in jquery??
Asked
Active
Viewed 2,400 times
1 Answers
2
Assuming the following HTML as an example:
<div class="div">
<input type="text" />
<input type="text" />
<input type="text" />
</div>
<input type="text" class="b"/>
One can use the following script, using the focus and blur events:
$('.div input[type="text"]').on('focus', function(){
$('.b').prop('disabled', true);
}).on('blur', function(){
$('.b').prop('disabled', false);
});
Check Fiddle

Nope
- 22,147
- 7
- 47
- 72

Sushanth --
- 55,259
- 9
- 66
- 105
-
+1, wihtout OP giving any information or markup this is a valid example. Although, the use of classes on any controls which should disable/enable other elements may or may not be slightly more efficient than targeting all inputs by either specific type or just `input`. – Nope Oct 09 '12 at 12:32