, <q>, <samp>, <select>, <small>, <span>,<strong>, <sub>, < ;sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>,<th>, <thead>, <tr>, <tt>, < ;ul>, <var><br/></p><p>JavaScript objects that support this event: </p><p>button, checkbox, fileUpload, layer, frame, password,radio, reset, submit, text, textarea, window<br/></p><p>Example:</p><pre class='brush:php;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>
Copy after login
<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>
Copy after login
The above is the detailed content of How to remove focus in javascript. For more information, please follow other related articles on the PHP Chinese website!