1. 程式人生 > >(html4和html5區別)如何在一個input上新增焦點

(html4和html5區別)如何在一個input上新增焦點

html4:

<form>
<p><label>Username:<input name=search type="text" id="search"></label></p>
<script type="text/javascript">
document.getElementById ('search').focus()
</script>
</form>


html5:

<form>
<p>
    <label>Search:<input name=search autofocus></label>
</p>
</form>