只是想要一些快速的帮助 我 90% 确定我需要使用 (this( 调用/函数,因为我需要它来处理页面上的多个对象。 但是我不确定在哪里或如何将它放入我的jQuery代码中,一旦用户将鼠标悬停在另一个对象上,我就会尝试为一个对象创建悬停状态, 这是我的jquery代码,希望这是有道理的,谢谢!
$("li.projectpost").hover(function () {
$("div.portfolio-title a").toggleClass("highlighter");
});
基本上我真正想知道的是,我想在页面上应用悬停效果的元素不止一个,就像现在一样,当我将鼠标悬停在一个项目上时,它们都会改变,但我想知道的是当滚动到父元素上时如何更改子元素中的 css,我想, 我有一个 Div 包装器,当将鼠标悬停在内部div 更改上时,这是否更有意义,仍在尝试围绕 jquery 进行思考,感谢您的帮助!:)
感谢大家的帮助!我刚刚想通了这一点,我需要使用 - jQuery(this(.find((;谢谢!
如果需要,可以传递两个回调函数来悬停。我不清楚你在那里做什么,但我认为这就是你需要的:
$("li.projectpost").hover(function () {
// This will call when mouse is over
}, function(){
// This will call when mouse is out
});
http://jsfiddle.net/tbq3x/13/
只需尝试上面的小提琴。您的代码工作正常。
感谢大家的帮助!我刚刚想通了这一点,我需要使用 -
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");
});
到目前为止,它似乎工作得很好! 再次感谢!
$("li.projectpost").hover(function () {
$(this).toggleClass("highlighter");
});
以上应该有效,告诉我它是怎么回事。
将代码放入$(document).ready()
方法
$(document).ready(function(){
$("li.projectpost").hover(function () {
$("div.portfolio-title a").toggleClass("highlighter");
});
});