I'm making a search bar with the text-bar as an tag, and the search-button as a , the reason I use a instead of is because I'm using a picture of a magnifying glass on the button, an when I use it doesn't want to position itself properly.
Here is my HTML:
<form id="search-form" href="#test1" class="smoothscroll">
<input type="text" id="searchText" onClick="this.select();" placeholder="Search..."/>
<button type="button" id="searchButton">
<img src="magnify.png" id="magnify"/>
</button>
</form>
And here is the jquery:
$(document).ready(function () {
$("#searchButton").click(function () {
var text = document.getElementById('searchText').value;
$("html, body").animate({
scrollTop: ($('#' + text).offset().top)
}, 2000);
});
$("#searchText").keyup(function (event) {
if (event.keyCode == 13) {
$("#searchButton").click();
}
});
});
Thank you for helping.