I am trying to Create a website and in which there is a button and i have gave it a link to redirect on same page like :-
<button><a href="#explore">Explore</a></button>
<div id="explore">
</div>
When i am opening or refreshing the page, without clicking on button it redirects me to #explore div but i want it to redirect on a click.
So please help me to solve this problem
Thanks in Advance :)
You should delete an anchor from an tag and put the functionality instead to a JS. For example:
<button id="buttonAnchor">Explore</button>
<div id="explore">
</div>
<script>
let btn = getElementById('buttonAnchor');
btn.onclick = function() {
explore = getElementById('explore');
window.scrollTp(0, explore.offsetTop;
}
</script>
you can use below code like...
Method-1
<button><a href="">Explore</a></button>
<div id="explore">
</div>
Method-2
<button><a href="#" id="myLink">Explore</a></button>
<script>
$("#myLink").click(function() {
window.location.reload();
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.