当前位置: 移动技术网 > IT编程>开发语言>JavaScript > Jquery实现的一种常用高亮效果示例代码

Jquery实现的一种常用高亮效果示例代码

2019年03月21日  | 移动技术网IT编程  | 我要评论

如下所示:

. 代码如下:


<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>
                注册选项</h5>
        </li>
        <li>用户名:<input type="text" value="" id="name" style="width: 200px" /></li>
        <li>密 码:<input type="password" value="" id="pass" style="width: 200px" /></li>
        <li>爱 好:<input type="checkbox" value="" />篮球 <input type="checkbox" value="" />足球 <input
            type="checkbox" value="" />音乐</li>
    </ul>
    </script>
</body>
</html>


如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网