在button click
我想scroll
到一个特定的div
。最初,div
是hidden
。两个事情发生在我的button click
滚动到div不工作在jQuery
- 股利应可见(它的工作),并
- 滚动到这个div(不工作)
我的代码是:
HTML
<input type="button" id="showbtn" value='Show'>
<div id="ref_div" style="display:none;">
<span class="small">Reference Number</span>
<input type="text" name="rnum" id="rnum" class="form-control form-control-solid placeholder-no-fix" placeholder="Reference Number" title="Reference Number"><br>
<input type="button" class="btn btn-success" id="ref_btn" name="ref_btn" value="Proceed"><br>
</div>
jQuery的
$("#showbtn").click(function() {
$("#ref_div").css('display', 'block');
});
$("#ref_btn").click(function() {
$('html, body').animate({
scrollTop: $("#ref_div").offset().top
}, 2000);
});
真的吗? 'display:none;'? – Dray
@ next2u我认为你正在尝试不可能的事情:) –
你想点击一个未呈现的按钮(display:none)并滚动到该div(在其中你刚刚点击过),只是一个问题:WTF? – enguerranws