0
我的頁面底部包含一個表單。當頁面加載瀏覽器給焦點的形式,當我想要的是頁面的頂部顯示。頁面加載時,如何防止關注表單(頁面底部)?
形式爲:
<section class="item" id="form_text">
<form id="form" name="queryForm" action="proc_query.php" method="get">
<input type="text" size="40" name="name" autofocus required placeholder="Name"><br><br>
<input type="text" size="40" name="phoneNum" placeholder="Phone No."><br><br>
<input type="email" size="40" name="email" placeholder="Email" required><br><br>
<textarea required rows="8" cols="41" name="comments" placeholder="Comments"> </textarea><br><br>
<input class="button" type="submit" name="submit" value="Send Query">
</form>
</section>
我試過在頁面的頂部分配焦點的元素但沒有奏效:
function getfocus() { document.getElementById("mi").focus(); }
您能否提供一個解?
刪除'name'輸入中的'autofocus'。 – forrestmid
試過....沒有工作。 – Trevor
https://jsfiddle.net/n0kkdeb0/完美地工作。如果它確實不適合你,可能是由其他原因引起的。發佈你的整個代碼。 –