有没有办法触发JavaScript中另一个项目后面的任何项目的onclick?

时间:2011-01-15 18:10:15

标签: javascript css javascript-events html

基本上,我使用不同的div来突出显示文本部分。基本上,我想知道用户是否点击了突出显示的选项。

然而。突出显示div位于文本后面,因此似乎没有调用div的onclick方法。有一些技巧可以解决这个问题吗?

谢谢, GRAE


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
    </head>
    <body>
        <div style="position: relative">
            <div style="width:200px;height:200px;background-color: seagreen; position: absolute; left: 40px; top: 40px; z-index: -1" onclick="alert('called?')"></div>
            <pre >
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!
This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!This is a test!

            </pre>
        </div>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

你可以这样做:

在你可以设置的高亮div上

z-index:1;
opacity:0.2; /* from 0 to 1*/
filter:alpha(opacity=20); /* IE opacity fix */

如果要显示高亮显示div,则必须设置不透明度

示例:http://jsfiddle.net/steweb/Cqvve/