我正在尝试重新加载页面,然后在用户点击“添加另一个”按钮时将页面/窗口向下滚动到页面的最底部。我已经尝试了jquery scrollTo和scrollTop函数但没有用,它可能无法在页面重新加载,请有人帮我这个。
刷新或重新加载页面的按钮是“anotherEducation”,我要向下滚动的div是“secondaryEducationForm”
<script>
function scroll(){window.scrollTo(0,750);
}
</script>
<div id="secondaryEducationForm">
<br/>
<form>
<label for="secondaryLevel" style="text-align:justify;">Select the level of qualification first (e.g. A level) then enter your grades and click on "Save"
To add other qualifcations (e.g. GCSE's) click on "Add another qualification"</label>
<br/>`
<select name="secondaryLevel" id="secondaryLevel" onChange="showdiv(this)" style="margin-bottom:25px;">
<option value="" selected disabled>Select</option>
<option value="1">A Level</option>
<option value="2">AS Level</option>
<option value="0">GCSE</option>
<option value="3">BTEC</option>
<option value="4">NVQ</option>
<option value="NULL">Other (Please State)</option>
</select>
<input type="text" name="secondaryLevelCustom" id="secondaryLevelCustom" value="" style="display:none;" />
<input type="submit" name="saveGCSEEducation" id="saveGCSEEducationSubmit" value="Save" />
<input type="submit" name="anotherEducation" id="anotherEducation" onclick="scroll();" value="Add Another Qualification" />
</form>
`
答案 0 :(得分:1)
您可以通过
将链接重定向到页面上的div<a href="pagename.html#yourDivId">Some Text</a>
答案 1 :(得分:1)
当用户点击另一个教育时,你必须存储真/假值或Flage,然后在重新加载页面检查后重新加载页面检查该值,iF是True然后向下滚动,否则什么也不做......
$(document).ready(function()){
function scroll(){
if(anotherEducation==true){
window.scrollTo(0,750);
}
else
//Do nothing..
}
)};
答案 2 :(得分:0)
尝试将div id附加到url并重新加载页面
<div id="yourform"> Place where you wanted to scroll down on page
load / reload </div>
喜欢这个
#yourform