【发布时间】:2014-01-05 13:20:15
【问题描述】:
我试图让用户翻转箭头,使 div 出现在下方(即使鼠标悬停后仍保留在那里)。我取得了一些成功,但碰壁了。
它只能从左到右工作,如果我想将鼠标悬停在左侧的箭头上并且我已经将鼠标悬停在右侧的箭头上,这是不可能的。
代码如下:
$(".business-strategy").one("mouseover", function() {
$(".business-strategy2").css("z-index", "10");
$(".accelerating-innovation2").css("z-index", "-1");
$(".cloud-and-technical-services2").css("z-index", "-1");
$(".procurement-and-supplier-services2").css("z-index", "-1");
});
$(".accelerating-innovation").one("mouseover", function() {
$(".business-strategy2").css("z-index", "-1");
$(".accelerating-innovation2").css("z-index", "10");
$(".cloud-and-technical-services2").css("z-index", "-1");
$(".procurement-and-supplier-services2").css("z-index", "-1");
});
$(".cloud-and-technical-services").one("mouseover", function() {
$(".business-strategy2").css("z-index", "-1");
$(".accelerating-innovation2").css("z-index", "-1");
$(".cloud-and-technical-services2").css("z-index", "10");
$(".procurement-and-supplier-services2").css("z-index", "-1");
});
$(".procurement-and-supplier-services").one("mouseover", function() {
$(".business-strategy2").css("z-index", "-1");
$(".accelerating-innovation2").css("z-index", "-1");
$(".cloud-and-technical-services2").css("z-index", "-1");
$(".procurement-and-supplier-services2").css("z-index", "10");
});
我对 JavaScript 很陌生,请原谅任何 newby 错误!
任何帮助将不胜感激! :-)
海蒂
【问题讨论】:
-
请不要链接到您的网站。原因如下:meta.stackexchange.com/questions/125997/…
-
使用
on代替one。这就是one的工作方式 -Attach a handler to an event for the elements. The handler is executed at most once per element per event type. -
@diodeus 更好的选择是 jsFiddle。
标签: javascript css hover z-index mouseover