I would like to change the width of input search box as soon as the cursor was placed in the input box.
However once the user click on any of the body element which is not input box, I would like the width go back to its original length. However it seems that the program also change the width back to its original length even when the cursor was placed in the search box. How do I select body element which is not input box.
var input = $(this).find('input[name="q"]');
/* Part A: Change the width of the search input box to 600px when cursor was
click on the search box. When I comment out part B, then the width will only change. If I does not comment out part B, the width remain the same */
input.bind('click', function(){
console.log("width changed");
$(this ).css({'width' : '600px'});
})
/* Part B: When user click on any body element which is not the input box,
change the width of the input box back to original length. It is
not working, when the cursor was placed in the input box, it also
executes this part of code, */
$("body *:not('.search_box')).bind('click', function(){
$('input:text').css({'width' : 'inherit'});
})
$('body').bind('click', function(){
$('.search-results').hide();
});
