Wenn sich die Maus auf das Textfeld von E -Mail -Adresse konzentriert, wird der Text "Bitte E -Mail -Adresse eingeben" im Textfeld gelöscht.
Reproduktionsbild:
Die Codekopie lautet wie folgt:
< %@ Page Language = "C#" AutoEventwireUp = "True" CodeFile = "Ähnlich wie der Eingabeaufenthalt von Yahoo -E -Mail -Login.aspx.cs" inerits = "Ähnlich wie die Eingabeaufforderung des Yahoo -E -Mail -Login" %>
<! DocType html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<meta http-äquiv = "content-type" content = "text/html; charset = utf-8"/>
<title> </title>
<script type = "text/javaScript" src = "scripts/jQuery-1.7.1.js"> </script>
<script type = "text/javaScript">
$ (function () {
// das Adressfeld bedienen
$ ("#Adresse"). Focus (function () {// Das Adressfeld erhält den Mausfokus
var txt_value = $ (this) .val ();
if (txt_value == "Bitte geben Sie Ihre E -Mail -Adresse ein") {{
$ (this) .val ("");
}
});
$ ("#Adresse"). Blur (function () {// Das Adressfeld verliert den Mausfokus
var txt_value = $ (this) .val ();
if (txt_value == "") {
$ (this) .val ("Bitte geben Sie Ihre E -Mail -Adresse ein");
}
})
// das Passwortbox betreiben
$ ("#password"). focus (function () {
var txt_value = $ (this) .val ();
if (txt_value == "Bitte geben Sie Ihr E -Mail -Passwort ein") {{
$ (this) .val ("");
}
});
$ ("#password"). Blur (function () {
var txt_value = $ (this) .val ();
if (txt_value == "") {
$ (this) .val ("Bitte geben Sie das E -Mail -Passwort ein);
}
})
});
</script>
</head>
<body>
<Form ID = "Form1" Runat = "Server">
<div>
<Eingabe type = "text" id = "adresse" value = "Bitte geben Sie Ihre E -Mail -Adresse ein" /> <br /> <br />
<Eingabe type = "text" id = "password" value = "Bitte geben Sie das E -Mail -Passwort ein" /> <br /> <br />
<input type = "button" value = "login" />
</div>
</form>
</body>
</html>