There is a submit button. and a textbox. I would like to hover on button with classname: search ,then toggle class to my textbox.
the problem is it is not work when I want to type in my textbox. How can I fix this?
Here is my codes:
$(".search").hover(function () {
$(".searchinput").toggleClass("searchinput2");
});
.searchinput{width:2%; height:30px; background:yellow; font-size:1.5em;}
.searchinput2{width:50% !important;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="text" class="searchinput"/>
<button type="submit" class="search">search</button>