, <q>, <samp>, <select>, <small>, <span>,<strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>,<th>, <thead>, <tr>, <tt>, <ul>, <var><br/></p><p>支持该事件的 JavaScript 对象:</p><p>button, checkbox, fileUpload, layer, frame, password,radio, reset, submit, text, textarea, window<br/></p><p>实例:</p><pre class="brush:js;toolbar:false"><html>
<head>
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("fname").value
document.getElementById("fname").value=x.toUpperCase()
}
</script>
</head>
<body>
Enter your name: <input type="text" id="fname" onblur="upperCase()"><br />
Enter your age: <input type="text" id="age" onblur="alert(this.id)">
</body>
</html>
登录后复制
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("input").focus(function(){
$("input").css("background-color","#FFFFCC");
});
$("input").blur(function(){
$("input").css("background-color","#D6D6FF");
});
});
</script>
</head>
<body>
Enter your name: <input type="text" />
<p>请在上面的输入域中点击,使其获得焦点,然后在输入域外面点击,使其失去焦点。</p>
</body>
</html>
登录后复制