0

只是想要一些快速帮助我 90% 确定我需要使用 (this) 调用/函数,因为我需要它来处理页面上的多个对象。但我不确定将它放在我的 jquery 代码中的位置或方式,一旦用户翻过另一个对象,我会尝试为一个对象创建悬停状态,这是我的 jquery 代码,我希望这是有道理的,谢谢!

    $("li.projectpost").hover(function () {
    $("div.portfolio-title a").toggleClass("highlighter");
    });

基本上我真正想知道的是,我想在页面上应用悬停效果的不止一个元素,就像现在一样,当我将鼠标悬停在一个项目上时,它们都会改变,但我想知道的是如何在父元素上滚动时更改子元素中的 css 我猜,我有一个 Div 包装器,当将鼠标悬停在内部 div 更改上时,这是否更有意义,仍然试图围绕 jquery 感谢您的帮助!:)

感谢大家的帮助!我刚刚想通了,我需要使用 - jQuery(this).find(); 谢谢!

4

5 回答 5

1

如果需要,您可以传递两个回调函数来悬停。我不清楚你在那里做什么,但我认为这是你需要的:

$("li.projectpost").hover(function () {
    // This will call when mouse is over
    }, function(){
    // This will call when mouse is out
   });
于 2011-08-18T04:38:35.130 回答
1

http://jsfiddle.net/tbq3x/13/

试试上面的小提琴。您的代码工作正常。

于 2011-08-18T04:39:59.540 回答
1

感谢大家的帮助!我刚刚想通了,我需要使用 -

jQuery(this).find(" "); 

为了选择彼此内部的元素,所以我的代码最终看起来像这样

    $("li.projectpost").hover(function () {
    // This will call when mouse is over
    jQuery(this).find(".portfolio-title a").css("color","#00fcff");
    }, function(){
    // This will call when mouse is out
    jQuery(this).find(".portfolio-title a").css("color","#ececec");
    });

到目前为止,它似乎工作得很好!再次感谢!

于 2011-08-18T17:13:10.680 回答
0
$("li.projectpost").hover(function () {
    $(this).toggleClass("highlighter");
});

以上应该有效,告诉我它是怎么回事。

于 2011-08-18T04:37:43.117 回答
0

将您的代码放入$(document).ready()方法中

$(document).ready(function(){

   $("li.projectpost").hover(function () {
    $("div.portfolio-title a").toggleClass("highlighter");
    });

});
于 2011-08-18T04:38:40.610 回答