<script src=/scripts/jquery-1.8.3.min.js></script><script>$(function() { $(":text").focus(function() { $(this).css('border-color', '#0f0'); }).blur(function() { $(this).css('border-color', ''); })});</script><input type=text><input type=text><input type=text><input type=text>
Is there any other way to write it? !
Just use a css pseudo-class
input:focus {
border-style: solid;
border-color: #339933;
}
input:focus{ border-style:solid; border-color:#339933}
input:focus{ border-style:solid; border-color:#339933}
input:focus{ border-style:solid; border-color:#339933}
<style type="text/css"> .green{ border-style:solid; border-color:#339933 }</style>$("#你的input的ID").focus( function(){ $("#你的div的ID").addClass("green"); }).blur( function(){ $("#你的div的ID").removeClass("green"); });