html學習筆記

來源:互聯網
上載者:User

標籤:for   asp   focus   分享   hone   載入   執行個體   image   text   

HTML5<input> placeholder屬性

執行個體 帶有placeholder文本的搜尋欄位:

1 <form action="demo_form.asp" method="get">2     <input type="search" name="user_search" placeholder="Serarch W3School"/>3     <input type="submit"/>4 </form>

定義和用法

palaceholder屬性提供可描述輸入欄位預期值的提示資訊.

該提示會在輸入欄位為空白時顯示,並會在欄位獲得焦點時消失.

注釋:placeholder屬性適用於以下的<input>類型:text,search,url,telephone,email以及password.

文法:<input placeholder="text">

 

HTML onload事件屬性

<!DOCTYPE html><html>    <head>         <script>          function load()          {          alert("頁面已載入!")           }         </script>     </head>    <body onload="load()">    <h1>Hello World!</h1>    </body></html>

 執行個體:頁面載入之後立即執行一段javascript;<body onload="load()">

定義和用法

onload屬性在對象已載入時觸發.

onload常用在<body>中,一旦完全載入所有內容(包括映像,指令檔,css檔案等),就執行一段指令碼.

 

HTML  onblur事件屬性

執行個體 :當使用者離開輸入欄位時對其進行驗證:

<input type="text" name="fname" id="fname" onblur="upperCase()">

定義和用法

onblur屬性在元素失去焦點時觸發.

onblur常用於表單驗證代碼(例如使用者離開表單欄位)

提示:onblur屬性與onfocus屬性相反

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title></title>        <script>            function upperCase(){                var x=document.getElementById("fname").value                document.getElementById("fname").value=x.toUpperCase()            }        </script>    </head>    <body>        <p>請輸入您的姓名,然後把焦點移動到欄位外:</p>        請輸入您的姓名(英文字元):<input type="text" name="fname" id="fname" onblur="upperCase()"/>    </body></html>

 

html學習筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.