Jump to content

This is a combo box Ajax appear by onkeyup event


lse123
 Share

Recommended Posts

<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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...