lse123 Posted May 23, 2011 Share Posted May 23, 2011 <input type="text" name="searchKeyword" id="searchKeyword" onkeyup="showResult(this.value)" /><div style="position:absolute;left:inherit; top:inherit; background:background-color:#CCCCCC" id="livesearch">I want remove this layer/div when click outside of it NOT inside, well what is the remove function? This is a combo box Ajax appear by onkeyup event... Link to comment Share on other sites More sharing options...
lse123 Posted May 23, 2011 Author Share Posted May 23, 2011 function hidediv(){ if (document.getElementById("livesearch").style.display == 'block' ) { document.getElementById("livesearch").style.display = 'none'; }}how call this function when click, outside the div? Link to comment Share on other sites More sharing options...
jeffman Posted May 23, 2011 Share Posted May 23, 2011 Testing for clicks outside a particular element can be very complicated. It also fails if your user tabs away from your element. A click listener won't know about that.Maybe what you want is to run your function if the text input loses focus? That would be as simple as adding this to your text input tag:onblur="hidediv()"Try it and see if it does what you want. Link to comment Share on other sites More sharing options...
lse123 Posted May 24, 2011 Author Share Posted May 24, 2011 worked but div close even click inside div... I want not close if click inside dive ... Link to comment Share on other sites More sharing options...
thescientist Posted May 24, 2011 Share Posted May 24, 2011 can you show us the code since you've made changes to it? Link to comment Share on other sites More sharing options...
lse123 Posted May 25, 2011 Author Share Posted May 25, 2011 http://www.polisphotos.com/store/test_livesearch.cfm I implement onclick only to DIVs on the left site of page[of search box],(not to search box div) so problem bypassed... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.