我很想知道,当鼠标悬停在父级上时,您如何定位子级?
我会如何使用CSS:
parent:hover child {
background-color: #FFFFFF;
}
如何在 jQuery 中做到这一点? “.medarbejdere .info span.kontaktinfo”是我的 parent 。我希望$(this)成为我的 child 。
var navDuration = 150; //time in miliseconds
var forstoer = "150px";
$('.medarbejdere .info span.kontaktinfo').hover(function() {
$(this).animate({ 'right' : "+="+forstoer }, navDuration);
}, function() {
$(this).animate({ 'right' : "-150px" }, navDuration);
});
提前谢谢您...
最佳答案
使用$(this).children()
。
例如:
var navDuration = 150; //time in miliseconds
var forstoer = "150px";
$('.medarbejdere .info span.kontaktinfo').hover(function() {
$(this).children().animate({ 'right' : "+="+forstoer }, navDuration);
}, function() {
$(this).children().animate({ 'right' : "-150px" }, navDuration);
});
关于jQuery悬停父级影响子级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2450023/