I am currently attempting a basic jQuery example to expand a search bar on mouse click, but for some reason, my code is not working as expected. I have a simple jQuery function to display the input field when the button with the class "expand" is clicked, however, upon clicking the button, the input field that is originally set to display:none in the CSS does not appear.
Here is my basic jQuery script:
<script type="text/javascript">
$('.expand').click(function() {
$('#test').show(500);
});
This is my HTML:
<nav id="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Contacts</a></li>
<li id="sb-search" style="float:right; list-style:none; height:20px;">
<div id="pesquisar-container">
<span id="pesquisar" class="form-container cf">
<form name="form1" >
<input id="test" type="search" placeholder="Pesquisar..." required="required" onfocus="if(this.placeholder == 'Search...') {this.placeholder=''}" onblur="if(this.placeholder == ''){this.placeholder ='Search...'}" />
<button class="expand" type="submit"><i class="fa fa-search"></i></button>
</form>
</span>
</div>
</li>
</ul>
</nav>
And this is my CSS styling:
.form-container input {
width: 150px;
height: 25px;
padding: 5px 5px;
float: left;
font-weight: bold;
font-size:15px;
font-family:'bariol_lightlight';
border: 0;
background: #f3f3f3; /*#fcfcfc se o fundo for branco, ver as diferenças */
border-radius: 3px 0 0 3px;
margin-top: 9px;
color:#000;
display:none;
}
.form-container button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 25px;
width: 35px;
text-transform: uppercase;
background: #363f48;
border-radius: 0 5px 5px 0;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
margin-top:9px;
}