function close() {
console.log('close');
$("#display").hide();
}
I am trying to call a closefunction when the user clicks out of the input box, but it doesn’t seem to be working.
Doesn’t work:
<input type="text" name="searchQuery" id="searchQuery" onblur="javascript: close();" onkeyup="javascript: getSuggest(); "/>
Works:
<input type="text" name="searchQuery" id="searchQuery" onblur="javascript: alert('msg');" onkeyup="javascript: getSuggest(); "/>
getSuggest returns false if that’s relevant.
Change the function name from close to something else since the close function is part of the window object.
Additionally your function declaration cannot be specified after any type of dom-ready event observers have fired.
Example: notice if you wait for window.load or dom.ready the function doesn’t get attached to the dom element (input)
EDIT
http://jsfiddle.net/bb84T/5/