jquery获取单击的节点对象

event.target

<script language="JavaScript" type="text/javascript">

        $("document").ready(function () {
            $(".menu").bind("click", function (event) {
                var clickedNode = event.target;
                var NodeType = event.target.nodeName;
                if (NodeType == "DIV") {
                    return;
                }
                if (NodeType == "INPUT") {
                    var DivId = clickedNode;
                    $(".menu").removeClass('addborder');
                    $(DivId.parentNode).addClass('addborder');
                }
                if (NodeType == "A") {
                    var DivId = clickedNode;
                    $(".menu").removeClass('addborder');
                    $(DivId.parentNode.parentNode).addClass('addborder');
                }        })

          </script>

解释: 其中event.target 即为处罚单击事件的对象 (有可能是容器内部的某个控件)

posted @ 2011-07-08 13:27  郑文亮  阅读(2203)  评论(0编辑  收藏  举报