I am trying to create a simple code that expands a box when the search button is clicked. Below is the HTML code:
<a id="displayText" href="javascript:toggle();"><img src="images/search.png"></a>
<div id="toggleText" style="display: none;">
<form>
<input type="text" name="" placeholder="search">
</form>
</div>
Here is my JavaScript code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
if(ele.style.display == "block") {
ele.style.display = "none";
}
else {
ele.style.display = "block";
}
}
</script>
The code is working well, but I want to add a smooth effect when expanding. Can anyone help me with this? Thank you!