jQuery聚焦控件的高亮显示,body *表示body标签内的所有元素标签

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>

    <script src="js/jquery-1.4.2.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function() {
            //body *   body空格*表示body标签内的所有元素标签
            $("body *").click(function() {
                $(this).addClass("bg").siblings().removeClass("bg");
            });
        })
    </script>

    <style type="text/css">
        .bg
        {
            background-color: Yellow;
        }
    </style>
</head>
<body>
    <input type="text" />
    <input type="button" />
    <input type="checkbox" />
    <div>
        111
    </div>
    <p>
        222</p>
</body>
</html>

 

posted @ 2013-07-23 16:16  ipangjie  阅读(412)  评论(0)    收藏  举报