當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML button用法及代碼示例

HTML中的<button>標記用於定義可單擊的按鈕。 <button>標記用於提交內容。圖像和文本內容可以在<button>標記內使用。

用法:

<button type = "button">

例:

<!DOCTYPE html> 
<html> 
    <head> 
        <title>button tag</title> 
    </head> 
      
    <body> 
        <p>button tag</p> 
          
        <!-- button tag starts from here -->
        <button type = "button" onclick =  
            "alert('Welcome to GeeksforGeeks')"> 
            Click Here 
        </button> 
        <!-- button tag ends here -->
          
    </body> 
</html>                    

輸出:

注意:

  • 不同的瀏覽器為<button>使用不同的默認類型。
  • 可以使用CSS設置按鈕樣式。
  • HTML5添加了一些新屬性。
    • autofocus
    • form
    • formaction
    • formnovalidate
    • formenctype
    • formmethod
    • formtarget

支持的瀏覽器:<button>標記支持的瀏覽器如下:

  • 穀歌瀏覽器
  • IE瀏覽器
  • Firefox
  • Safari
  • Opera

相關用法


注:本文由純淨天空篩選整理自sheyakhare1999大神的英文原創作品 HTML | button Tag。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。