Jquery implements a commonly used example code for highlighting effects

  • 2020-03-30 01:34:01
  • OfStack

As follows:


<html>
<head>
    <title>jquery</title>
    <style>
        body
        {
            font-size: 12px;
        }
        li
        {
            list-style: none;
            height: 34px;
            padding-top: 5px;
        }
    </style>
    <script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
    <script type="text/javascript">
$(document).ready(function(){    
    var oInputs = $("ul.demo input");
    oInputs.each(function(i){
        oInputs.eq(i).focus(function(){
            oInputs.eq(i).parent().css("background-color","ccf");
        }).blur(function(){
            oInputs.parent().css("background-color","");
        })
     }); 

    
    oInputs.focus(function(){
        $(this).css("background-color","ff9").blur(function(){
            $(this).css("background-color","");
        });
    })
})
    </script>
</head>
<body>
    <ul class="demo">
        <li>
            <h5>
                 Registration options </h5>
        </li>
        <li> The user name :<input type="text" value="" id="name" style="width: 200px" /></li>
        <li> The secret   code :<input type="password" value="" id="pass" style="width: 200px" /></li>
        <li> love   good :<input type="checkbox" value="" /> basketball  <input type="checkbox" value="" /> football  <input
            type="checkbox" value="" /> music </li>
    </ul>
    </script>
</body>
</html>


Related articles: