关于span嵌套的问题
我的页面文件如下:
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head>
<title> 无标题页 </title>
</head>
<body>
<script type= "text/javascript ">
function aaa()
{
//处理事件
}
</script>
<span onclick= "aaa(); " style= "cursor:hand; z-index:999; " id= "rile ">
<img id= "rile1 " style= "z-index:1; " src= "images/Head/Head13.gif "/>
<span id= "rile2 " style= "z-index:1; "> sdsdf;ldsfllksdjf </span>
</span>
</body>
</html>
------------------------------------------------
我的目的是想在点击了最外层的span之后触发一个事件,但是,事实上,用event.srcElement.id可以得知,并不是每次得到的都是最外层的span的ID,但是我就是想在点击了最外层的span时才触发aaa()事件的。。要这么弄啊。。请高手不吝赐教...
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<head>
<title> 无标题页 </title>
</head>
<body>
<span onclick= "alert(this.id); " style= "cursor:hand; z-index:999; " id= "rile ">
<img id= "rile1 " style= "z-index:1; " src= "images/Head/Head13.gif "/> ssf
sadfa
sdf
as
df
as
f <br>
<span id= "rile2 " style= "z-index:1;back-Groundcolor:red; " > sdsdf;ldsfllksdjf </span>
</span>
</body>
</html>
------解决方案--------------------需要设置个width
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head>
<title> 无标题页 </title>
</head>
<body>
<script type= "text/javascript ">
function aaa()
{
alert(event.srcElement.id)
}
</script>
<span onclick= "aaa(); " style= "cursor:hand; z-index:999;width:600;background-color:red " id= "rile ">
<img id= "rile1 " style= "z-index:1; " src= "images/Head/Head13.gif "/>
<span id= "rile2 " style= "z-index:1; "> sdsdf;ldsfllksdjf </span>
</span>
</body>
</html>