添加:悬停选择器到类1时悬停在类2上 [英] add :hover selector to class 1 when hovering over class 2

查看:97
本文介绍了添加:悬停选择器到类1时悬停在类2上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将鼠标悬停选择器添加到类中,方法是将鼠标悬停在不同的div上。基本上有2个div形成一个按钮。顶部是在盘旋时改变颜色的部分,底部仅是图像。目前,悬停只适用于顶部,但我希望在悬停图片时也可以调用:悬停选择器。



基本上它不起作用一个按钮,而是两个按钮。



这是我的,但显然这是行不通的。

  $(。module-feature-img)。hover(function(){
$(。module-title-bottom)。attr('class','.module-title-bottom:悬停')
});

另外,我注意到在我将鼠标移开后,它仍然保持这种状态。



帮助将不胜感激






编辑

>

功能网站:
www.exo-l.com



这是关于底部的按钮 p>

我也意识到这并不是真的有效,因为有4个按钮,它们都有相同的类别。所以如果我将鼠标悬停在1张图片上,它们都会得到:悬停选择器。任何想法?

解决方案

您可以使用这个: http://jsfiddle.net/ZTU5v/

  $(。module-feature ()函数(){
$(。module-title-bottom)。addClass('hover');
} .module-title-bottom)。removeClass('hover');
});

添加回调函数以删除类。


I'm trying to add the :hover selector to a class when hovering over a different div. Basically there are 2 divs forming a button. The top part is the part that changes color when hovered over and the bottom part is simply an image. Currently, the hover only works for the top part, but I want the :hover selector to be called when hovering over the image too.

Basically it doesn't function as a single button but rather two buttons.

This is what I have but obviously this doesn't work.

$(".module-feature-img").hover(function(){
   $(".module-title-bottom").attr('class', '.module-title-bottom:hover') 
});

Also, I noticed that it stays stuck like that after I move my mouse away.

Help would be greatly appreciated


EDIT

Functioning site: www.exo-l.com

It's about the buttons on the bottom

I also realized this is not really going to work because there are 4 buttons and they all have the same class.. so if I hover over 1 image, they all would get the :hover selector. Any ideas?

解决方案

you can use this: http://jsfiddle.net/ZTU5v/

$(".module-feature-img").hover(function(){
  $(".module-title-bottom").addClass('hover');
}, function(){
  $(".module-title-bottom").removeClass('hover');
});​

add a callback function to remove the class.

这篇关于添加:悬停选择器到类1时悬停在类2上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆