Jump to content

This is a combo box Ajax appear by onkeyup event


lse123

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...