日期:2014-05-17  浏览次数:20515 次

在HTML5中自动设置Form的焦点

下面的例子展示了你如何在HTML5中设置Form的焦点。通过设置autofocus属性。

<!DOCTYPE html>
<html>
<head>
    <title>Autofocusing a form input text control in HTML5</title>
</head>
<body>
 
    <form>
        <label for="usernom">Username:</label>
        <input id="usernom" type="text" autofocus /><br/>
 
        <label for="passwrd">Password:</label>
        <input id="passwrd" type="password" /><br/>
 
        <input type="reset" value="Reset" />
        <input type="submit" value="Log in" />
    </form>
 
</body>
</html>
?

源码下载:?

autofocusing-a-form-input-text-control-in-html5.zip