当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


HTML <select> autofocus属性用法及代码示例


HTML <select>自动对焦属性用于指定在页面加载时下拉列表应自动获得焦点。它是布尔属性的一种。

用法:

<select autofocus>

例:此示例说明了select元素中自动对焦属性的使用。


<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
      HTML select autofocus Attribute 
  </title> 
</head> 
  
<body style="text-align:center"> 
    <h1 style="color:green;"> 
      GeeksforGeeks 
  </h1> 
    <h2> 
      HTML <select> autofocus Attribute 
  </h2> 
        <select autofocus> 
            <option value="binary"> 
              Binary Search 
          </option> 
            <option value="linear"> 
              Linear Search 
          </option> 
            <option value="interpolation"> 
              Interpolation Search 
          </option> 
        </select> 
</body> 
  
</html>

输出:

支持的浏览器:HTML | <select>自动对焦属性如下所示:

  • 谷歌浏览器
  • IE浏览器
  • Firefox
  • Opera
  • Safari


相关用法


注:本文由纯净天空筛选整理自ManasChhabra2大神的英文原创作品 HTML | <select> autofocus Attribute。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。