/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> $(document).ready(function(){ $('input').focus(function() { $(this) .parent().addClass('highlight') }); $('input').blur(function(){ $(this) .parent().removeClass('highlight') }); }); </script> <style type="text/css"> .input { padding:6px; width:315px; border: 1px solid #fff; } input { border:4px solid #666; padding:4px; width:300px; } .highlight { background-color:#FF6; border: 1px solid #FC6; } </style> <div class='input'> Name:<br/> <input name='Name' type='text'/> </div> <div class='input'> Email:<br/> <input name='Email' type='text'/> </div> <div class='input'> Town:<br/> <input name='Email' type='text'/> </div>
URL: http://papermashup.com/jquery-form-highlighting/