function tdB.onclick()
{
  if(event.srcElement.tagName != "TD") return false;
  ;//下面放你的程序
}

解决方案 »

  1.   

    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <script language="JavaScript">
    function click_tdB()
    {
    if(event.srcElement != tdB) return false;
    alert("点击了tdB!");
    }function click_tbl2()
    {
    alert("点击了tbl2中的某处!")
    }
    </script>
    </HEAD><BODY>
    <TABLE id="tbl1" border=1 width=600>
    <TR>
    <TD>这个表格是tbl1</TD>
    <TD id="tdB" onclick="click_tdB();">(tdB)点击这里<br>
    <TABLE id="tbl2" border=1 width="100%" onclick="click_tbl2();">
    <TR>
    <TD>这个表格是tbl2</TD>
    <TD>点击这个表格</TD>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
    </TR>
    </TABLE>
    </TD>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
      

  2.   

    cancelBubble--------------------------------------------------------------------------------DescriptionSpecifies whether the current event should bubble up the hierarchy of event handlers. Syntax
    object.cancelBubble[ = cancelBubble]
    SettingsThis read-write property takes a Boolean value: TRUE  Cancels bubbling for this event, preventing the next event handler in the hierarchy from receiving the event. 
    FALSE  Enables bubbling. This is the default value. 
    Using this property to cancel bubbling for an event does not affect subsequent events. ExampleThe following document fragment cancels bubbling of the onclick event if it occurs in the IMG element when the SHIFT key is down. This prevents the event from bubbling up to the onclick event handler for the document. <SCRIPT LANGUAGE="JScript">
    function checkCancel() {
    if (window.event.shiftKey)
        window.event.cancelBubble = true;
    }
    function showSrc() {
        if (window.event.srcElement.tagName == "IMG")
            alert(window.event.srcElement.src);
    }
    </SCRIPT>
    <BODY onclick="showSrc()">
    <IMG onclick="checkCancel()" SRC="sample.gif">
      

  3.   

    kingdomzhf(旭日东升):我试了event.cancelBubble好像不行
      

  4.   

    谢谢:GageCSDN(稻草人) 
       在了解你的程序,为什么会运行子表中的事件?其实我在解决的是,我用一个js文件把网页上的格表,加上ID 加上事件,进行处理,这时处理子表就没有同样的效果.呵.修改中,
    万分感谢!
      

  5.   

    window.event.cancelBubble = true;事件就不会再往上层元素发了!
    http://expert.csdn.net/Expert/TopicView1.asp?id=2582796