如何用JS实现两个DIV或链接的事件同步
<div id="a1"></div>
<div id="a2"></div>
如何用JS实现两个DIV或链接的mouseover,click,doubleclick等鼠标事件同步???
------解决方案--------------------<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<center>
<script type="text/javascript">
//alert(/((\WWorld\W)|(\WBusiness\W))/.test("World World"))
//alert(/((\WWorld\W)|(\WBusiness\W))/.test("Business Business"))
</script>
</table>
</center>
</body>
<div id="a1" > 1`1111111111111111111</div >
<div id="a2" > 2222222222222222222222222</div >
<script type="text/javascript">
function divclick(){
alert("123")
}
document.getElementById("a1").onclick=function() {
divclick();
}
document.getElementById("a2").onclick=function() {
divclick();
}
document.getElementById("a1").onmouseover=function() {
divclick();
}
</script>
</html>
------解决方案--------------------document.getElementById("a1").onclick=function() {
divclick();
}
function divclick(){
document.getElementById("a2").onclick=function() {
divclickaaaaaaaaaaa();
}
}
function divclickaaaaaaaaaaa(){
alert("11")
}
在1里面调那个函数,
方法知道了,剩下的就是自己问题了
------解决方案--------------------<script language="javascript">
<!--
function onover(){
var objs=document.getElementsByTagName("div");
for(i=0;i<objs.length;i++){
if(objs[i].className=="dContainer") objs[i].innerText="onover";
}
}
function onout(){
var objs=document.getElementsByTagName("div");
for(i=0;i<objs.length;i++){
if(objs[i].className=="dContainer") objs[i].innerText="onout";
}
}
function onclk(){
var objs=document.getElementsByTagName("div");
for(i=0;i<objs.length;i++){
if(objs[i].className=="dContainer") objs[i].innerText="onclk";
}
}
function ondblclk(){
var objs=document.getElementsByTagName("div");
for(i=0;i<objs.length;i++){
if(objs[i].className=="dContainer") objs[i].innerText="ondblclk";
}
}
-->
</script>
<style type="text/css">
<!--
.dContainer{
position:absolute;
width:200px;
height:100px;
background:#CCCCCC;
mouse: expression(
onmouseover=function(){onover();},
onmouseout=function(){onout();},
onclick=function(){onclk();},
ondblclick=function(){ondblclk();}
)
}
-->
</style>
<div id="a1" class="dContainer" style="left:50px;top:50px;"></div>
<div id="a2" class="dContainer" style="left:350px;top:50px;"></div>
------解决方案--------------------<script language="javascript">
<!--
function umove(sender){
X=sender.style.left;
Y=sender.style.top;
offsetX=event.clientX-Number(X.substr(0,X.length-2));
offsetY=event.clientY-Number(Y.substr(0,Y.length-2));
var objs=document.getElementsByTagName("div");