How can i get Select box close event when click out of the select box any where in window.
My requirement is. I want to focus on another input on select box close event.
I tried with so many j Query events but i can't find any click event on window (browser) when select box is open.
Here i am sharing you my step to check an example.
- When click on select box and you'll have 'body clicked' in Console.
- Click outside of the box any where in window and you'll find that select box is close but you won't get any event. :(
- I am getting an on Change event but only when i select some value, but i want if someone click out side of select box the it should be close as we have but we can drive focus on other element as well.
Please find following static example for the same, it's very simple code (example), so I am not generating jsfiddle.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
$(window).click(function(){
console.log("body clicked");
});
});
</script>
</head>
<body>
<select id="mySelect">
<option value="0">Initial Value 1</option>
<option value="1">Initial Value 2</option>
<option value="2">Initial Value 3</option>
<option value="3">Initial Value 4</option>
</select>
</body>
</html>