English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML onblur-Event-Attribut

Die onblur-Property wird verwendet, um den Event-Handler für das onBlur-Event des aktuellen Elements abzurufen oder zu setzen

HTML Event Attributes

Online-Beispiel

Formatprüfung durchführen, wenn der Cursor das Eingabefeld verlässt:

<!DOCTYPE html>
<html>
<head>
<title>HTML onblur 事件属性的使用(基础教程网 oldtoolbag.com)</title>
<script>
function upperCase()
{
    var x=document.getElementById("fname").value
    document.getElementById("fname").value=x.toUpperCase()
{}
</script>
</head>
<body>
<p>Enter your name and then move the cursor/Tab out of the input box:</p>
Enter your English name (the mouse will be converted to uppercase when moved away): <input type="text" name="fname" id="fname" onblur="upperCase()">
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the onblur event attribute

Definition and Usage

The onblur attribute triggers when an element loses focus.

Onblur is most commonly used with form validation code (e.g., when the user leaves a form field).

Tip: The opposite attribute of onbluronfocus Attributes.

HTML 4.01 and HTML5Differences between

No difference.

Syntax

<element onblur="script">

Attribute Value

ValueDescription
scriptSpecifies the script to be executed when the onblur event is triggered
HTML Event Attributes