Issue
I have:
<button class="contactButton">XYZ</button>
And when user will press this button I want my page to scroll down to specific div.
I tried this:
$(".contactButton").click(function () {
$("html,body").animate({
scrollTop: $(".specificDivClass").offset().top
}, 1100);
});
Solution
Here you go with a solution https://jsfiddle.net/psfLbo1n/
$(".contactButton").click(function () {
$("html,body").animate({
scrollTop: $(".specificDivClass").offset().top
}, 1100);
});
.div1{
height: 700px;
width: 100%;
background: red;
}
.specificDivClass{
height: 1000px;
width: 100%;
background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="contactButton">XYZ</button>
<div class="div1">
</div>
<div class="specificDivClass">
</div>
Answered By - Shiladitya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.