我正在尝试重新加载页面,然后在用户单击“添加另一个”按钮时将页面/窗口向下滚动到页面的最底部。我已经尝试过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>


`

最佳答案

您可以通过以下方式将链接重定向到页面上的div:

<a href="pagename.html#yourDivId">Some Text</a>

关于javascript - 在按钮上单击可重新加载页面,但滚动到底部,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22250187/

10-12 12:47
查看更多