html的DOM中Event對象onblur事件用法執行個體,domonblur

來源:互聯網
上載者:User

html的DOM中Event對象onblur事件用法執行個體,domonblur

本文執行個體講述了html的DOM中Event對象onblur事件用法。分享給大家供大家參考。具體分析如下:

onblur 事件會在對象失去焦點時發生。

文法如下:
複製代碼 代碼如下:onblur="SomeJavaScriptCode"
SomeJavaScriptCode 必需。規定該事件發生時執行的 JavaScript。

支援該事件的 HTML 標籤:

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>,
<button>, <caption>, <cite>, <dd>, <del>, <dfn>, <div>, <dl>, <dt>,
<em>, <fieldset>, <form>, <frame>, <frameset>, <h1> to <h6>, <hr>, <i>,
<iframe>, <img>, <input>, <ins>, <kbd>, <label>, <legend>, <li>,
<object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>,
<strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>,
<th>, <thead>, <tr>, <tt>, <ul>, <var>

支援該事件的 JavaScript 對象:

button, checkbox, fileUpload, layer, frame, password,
radio, reset, submit, text, textarea, window

例子:在使用者離開輸入框時執行 JavaScript 代碼:
複製代碼 代碼如下:<html>
<head>
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("fname").value
document.getElementById("fname").value=x.toUpperCase()
}
</script>
</head>
<body>

輸入您的姓名:
<input type="text" id="fname" onblur="upperCase()" />

</body>
</html>

希望本文所述對大家的javascript程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.