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/完美地工作。如果它确实不适合你,可能是由其他原因引起的。发布你的整个代码。 –