Javascript 组中单个项的jQuery悬停
我有一组动态填充的div,突出显示个人的照片和姓名,总共大约有一百张: HTML: 我想写一点jQuery,当你将鼠标悬停在包含图像的链接上时,该链接的样式和包含名称的链接都会改变,反之亦然 我有这个:Javascript 组中单个项的jQuery悬停,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一组动态填充的div,突出显示个人的照片和姓名,总共大约有一百张: HTML: 我想写一点jQuery,当你将鼠标悬停在包含图像的链接上时,该链接的样式和包含名称的链接都会改变,反之亦然 我有这个: $(document).ready(function(){ $(".profile-btn-bg a").hover(function(){ $("a.instructor-name").toggleClass("hovered"); }); $("a.
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(){
$("a.instructor-name").toggleClass("hovered");
});
$("a.instructor-name").hover(function(){
$(".profile-btn-bg a").toggleClass("hovered");
});
});
但这改变了他们所有人,而不仅仅是我所关注的群体。有什么想法吗?您需要将搜索限制在最近的
.profile pic wrap
元素中
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(){
$(this).closest('.profile-pic-wrap').find("a.instructor-name").toggleClass("hovered");
});
$("a.instructor-name").hover(function(){
$(this).closest('.profile-pic-wrap').find(".profile-btn-bg a").toggleClass("hovered");
});
});
您需要将搜索限制在最近的
.profile pic wrap
元素内
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(){
$(this).closest('.profile-pic-wrap').find("a.instructor-name").toggleClass("hovered");
});
$("a.instructor-name").hover(function(){
$(this).closest('.profile-pic-wrap').find(".profile-btn-bg a").toggleClass("hovered");
});
});
您需要将搜索限制在最近的
.profile pic wrap
元素内
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(){
$(this).closest('.profile-pic-wrap').find("a.instructor-name").toggleClass("hovered");
});
$("a.instructor-name").hover(function(){
$(this).closest('.profile-pic-wrap').find(".profile-btn-bg a").toggleClass("hovered");
});
});
您需要将搜索限制在最近的
.profile pic wrap
元素内
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(){
$(this).closest('.profile-pic-wrap').find("a.instructor-name").toggleClass("hovered");
});
$("a.instructor-name").hover(function(){
$(this).closest('.profile-pic-wrap').find(".profile-btn-bg a").toggleClass("hovered");
});
});
您可以处理传递给悬停回调的默认参数(
Event-eventObject
),例如:
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(event){
event.target.toggleClass("hovered");
});
$("a.instructor-name").hover(function(event){
event.target.toggleClass("hovered");
});
});
您可以处理传递给悬停回调的默认参数(
Event-eventObject
),例如:
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(event){
event.target.toggleClass("hovered");
});
$("a.instructor-name").hover(function(event){
event.target.toggleClass("hovered");
});
});
您可以处理传递给悬停回调的默认参数(
Event-eventObject
),例如:
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(event){
event.target.toggleClass("hovered");
});
$("a.instructor-name").hover(function(event){
event.target.toggleClass("hovered");
});
});
您可以处理传递给悬停回调的默认参数(
Event-eventObject
),例如:
$(document).ready(function(){
$(".profile-btn-bg a").hover(function(event){
event.target.toggleClass("hovered");
});
$("a.instructor-name").hover(function(event){
event.target.toggleClass("hovered");
});
});