I have this code https://fiddle.jshell.net/cabeqaky/26/
The question is how to make that on first
div click
, input get focus and on
second
div click
input get unfocused. How to do that? :)
HTML
<input class="inp" type="text">
<div class="box"></div>
CSS
.box{
width:50px;
height:50px;
background-color:green;
margin-top:10px;
border:1px black solid;
cursor:pointer
}
You can use mousedown event on div and check for if the input has focus. e.preventDefault() is used to avoid the focus to be on div element on mousedown event.