마우스가 이메일 주소 텍스트 상자에 초점을 맞추면 텍스트 상자에서 "이메일 주소를 입력하십시오"텍스트가 지워집니다.
생식 이미지 :
코드 사본은 다음과 같습니다.
< %@ page language = "c#"autoeventwireup = "true"codefile = "yahoo 이메일 로그인의 신속한 효과와 유사합니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Head Runat = "Server">
<meta http-equiv = "content-type"content = "text/html; charset = utf-8"/>
<제목> </title>
<script type = "text/javaScript"src = "scripts/jquery-1.7.1.js"> </script>
<script type = "text/javaScript">
$ (function () {
// 주소 상자를 작동합니다
$ ( "#address"). focus (function () {// 주소 상자가 마우스 초점을 가져옵니다.
var txt_value = $ (this) .val ();
if (txt_value == "이메일 주소를 입력하십시오") {
$ (this) .val ( "");
}
});
$ ( "#address"). blur (function () {// 주소 상자는 마우스 초점을 잃습니다
var txt_value = $ (this) .val ();
if (txt_value == "") {
$ (this) .val ( "이메일 주소를 입력하십시오");
}
})
// 비밀번호 상자를 작동합니다
$ ( "#password"). focus (function () {
var txt_value = $ (this) .val ();
if (txt_value == "이메일 비밀번호를 입력하십시오") {
$ (this) .val ( "");
}
});
$ ( "#password"). blur (function () {
var txt_value = $ (this) .val ();
if (txt_value == "") {
$ (this) .val ( "이메일 비밀번호를 입력하십시오");
}
})
});
</스크립트>
</head>
<body>
<form id = "form1"runat = "Server">
<div>
<입력 유형 = "텍스트"id = "주소"value = "이메일 주소를 입력하십시오" /> <br /> <br />
<입력 유형 = "text"id = "password"value = "이메일 비밀번호를 입력하십시오" /> <br /> <br />
<입력 유형 = "버튼"value = "로그인" />
</div>
</form>
</body>
</html>