【发布时间】:2014-01-28 17:41:14
【问题描述】:
所以,这里有一些代码:
<!DOCTYPE html>
<html>
<head><title></title>
<script language = 'Javascript' type = 'text/javascript' src = 'jquery-1.10.2.js'></script> // jquery link there
<script language = 'Javascript' type = 'text/javascript'>
$(function() {
$('#div1').mousedown(function(event) { $(this).css(bla).css(bla) });
$('#div2').mousedown(function(event) { $(this).css(blah).css(blah) });
}); // end document.ready
</script></head>
<body>
<div id = 'div1' style = 'position: absolute; left: 50px;
top: 50px; z-index: 2; width: 50px; height: 50px; margin: 0px; padding: 0px;
border: 1px blue solid;'>Here</div>
<div id = 'div2' style = 'position: absolute; left:30px;
top: 50px; z-index: 1; width: 200px; height: 200px; margin: 0px; padding: 0px;
border: 1px blue solid; background-color: blue;'></div>
</body>
</html>
div 相对于 body 的位置很重要,所以我不会将一个包含在另一个中。但是,我会同时单击两个 div。如何让 mousedown 事件首先在 #div1 上触发,然后在 #div2 上触发,而不将第二个 div 放在第一个 div 内? (或相反亦然)。我觉得这很简单,所以请原谅我的愚蠢。如果以某种方式这样做是不可能的,有没有办法用 jquery 合成 #div2 事件?谢谢。
【问题讨论】:
标签: jquery html events mousedown simultaneous