JavaScript:z-index 在第一次鼠标悬停后不会改变
JavaScript: z-index doesn't change after first mouseover
我试图允许用户滚动箭头,使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 错误!
任何帮助将不胜感激! :-)
海蒂
JS
$(".business-strategy").on("mouseenter", 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");
})
.mouseleave(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").on("mouseenter", 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");
}).mouseleave(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").on("mouseenter", 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");
}).mouseleave(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").on("mouseenter", 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");
}).mouseleave(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");
});
或
您可以将这两个$(document).on('mouseenter mouseleave', '.classname', function (ev) {
结合起来,然后再次编写所有函数。
相关文章:
- jQuery:当屏幕大小改变时,如何更改默认图像和悬停图像
- JavaScript:z-index 在第一次鼠标悬停后不会改变
- Jquery下拉菜单改变悬停时的字体重量
- 改变悬停组件的背景颜色
- 改变悬停时的z指数(弹跳)
- 如何改变悬停时另一个链接的颜色
- 如何使文字慢慢改变悬停的颜色
- jQuery自动完成建议列表不会改变悬停时的背景颜色
- 改变循环中元素的背景,然后改变悬停的颜色
- 改变悬停样式颜色效果的函数
- 如何改变悬停列表显示/关闭Magento社区
- 图标不改变悬停
- 单击并保持图像,而不改变悬停到另一个图像
- 如何使用jquery改变悬停元素的颜色,并在鼠标离开时将其移除
- 在Wordpress中使用jQuery改变悬停元素的不透明度
- 类改变悬停父元素的跨度
- Jquery类改变悬停效果
- 改变悬停的边距会移动它下面的所有东西
- 改变悬停时的星级
- 改变悬停jquery的一部分Href