当图像和菜单项“标题”出现时,Jquery 会在悬停时更改图像彼此平等
现在这个问题已经解决了。我简化了代码。
我现在的问题是,每当我将鼠标悬停在所有列表项(如 ul.menu 下面所示)上,然后再次悬停在上面时,经检查 style="display:none;" 在我返回后不会被删除再次将鼠标悬停。
当前 Html:
<ul class="menu">
<li class="menu-mlid-187" id="ElDorado"><a title="El Dorado" href="/el-dorado">El Dorado</a></li>
<li class="menu-mlid-202" id="TheGrand"><a title="The Grand" href="/grand">The Grand</a></li>
</ul>
将鼠标悬停在每个菜单项上时需要更改的图像:
<div id="bannerContainer">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first">
<span class="field-content">
<a href="/el-dorado" class="imagefield imagefield-nodelink imagefield-field_image">
<img class="imagefield imagefield-field_image equal" width="636" height="420" alt="" title="El Dorado" src="http://localhost:8888/sites/default/files/eldoradobanner.jpg" />
</a>
</span>
</div>
</div>
<div class="views-row views-row-2 views-row-even views-row-last">
<span class="field-content">
<a href="/grand" class="imagefield imagefield-nodelink imagefield-field_image">
<img class="imagefield imagefield-field_image equal" width="636" height="420" alt="" title="The Grand" src="http://localhost:8888/sites/default/files/grandbanner.jpg" />
</a>
</span>
</div>
</div>
<!-- default image -->
<div id="upload">
<img width="636" height="561" title='venues' src="http://localhost:8888/sites/default/files/venues_banner.jpg" alt="" class="imagefield imagefield-field_image">
</div>
</div>
更新的 Jquery
// Dynamic mouse over menu item to display image utilizing titles
$('#content .menu-block-3 ul.menu a').mouseover( function(){
$("#bannerContainer #upload").fadeOut('fast');
var sharedtitle = $(this).attr("title");
$('#bannerContainer img[title = "'+sharedtitle+'" ]').fadeIn('fast');
});
$('#content .menu-block-3 ul.menu a').mouseout( function(){
$("#bannerContainer #upload").fadeIn('fast');
var sharedtitle = $(this).attr("title");
$('#bannerContainer img[title = "'+sharedtitle+'" ]').fadeOut('fast');
});
CSS:
/****** Venues Rollover navigation menu ******/
.view-ImageRollover {
float:left;
position:relative;
top: 0;
}
.view-ImageRollover .view-content { /* outer container */
position: relative;
}
.view-ImageRollover .field-content img { /* inner container */
display: block!Important;
float: left;
margin: 0;
padding: 0;
position: absolute;
top: 0px;
}
/* default image */
#upload {
float: left;
z-index: 5;
position: absolute;
}
#upload .imagefield-field_image img{
left:0px;
position: absolute;
}
有人知道我的问题是什么吗?如果我不清楚,请告诉我。我尝试将 display:block 添加到 .imagefield 但它被 jquery 覆盖并且不会返回到 block。
This is now solved. I simplified the code.
My problem now is that whenever I hover over all list items (shown below ul.menu) then hover over again, upon inspection style="display:none;" is not being removed after I come back to mouseover again.
Current Html:
<ul class="menu">
<li class="menu-mlid-187" id="ElDorado"><a title="El Dorado" href="/el-dorado">El Dorado</a></li>
<li class="menu-mlid-202" id="TheGrand"><a title="The Grand" href="/grand">The Grand</a></li>
</ul>
The images that need to change when each menu item is moused over:
<div id="bannerContainer">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first">
<span class="field-content">
<a href="/el-dorado" class="imagefield imagefield-nodelink imagefield-field_image">
<img class="imagefield imagefield-field_image equal" width="636" height="420" alt="" title="El Dorado" src="http://localhost:8888/sites/default/files/eldoradobanner.jpg" />
</a>
</span>
</div>
</div>
<div class="views-row views-row-2 views-row-even views-row-last">
<span class="field-content">
<a href="/grand" class="imagefield imagefield-nodelink imagefield-field_image">
<img class="imagefield imagefield-field_image equal" width="636" height="420" alt="" title="The Grand" src="http://localhost:8888/sites/default/files/grandbanner.jpg" />
</a>
</span>
</div>
</div>
<!-- default image -->
<div id="upload">
<img width="636" height="561" title='venues' src="http://localhost:8888/sites/default/files/venues_banner.jpg" alt="" class="imagefield imagefield-field_image">
</div>
</div>
Updated Jquery
// Dynamic mouse over menu item to display image utilizing titles
$('#content .menu-block-3 ul.menu a').mouseover( function(){
$("#bannerContainer #upload").fadeOut('fast');
var sharedtitle = $(this).attr("title");
$('#bannerContainer img[title = "'+sharedtitle+'" ]').fadeIn('fast');
});
$('#content .menu-block-3 ul.menu a').mouseout( function(){
$("#bannerContainer #upload").fadeIn('fast');
var sharedtitle = $(this).attr("title");
$('#bannerContainer img[title = "'+sharedtitle+'" ]').fadeOut('fast');
});
CSS:
/****** Venues Rollover navigation menu ******/
.view-ImageRollover {
float:left;
position:relative;
top: 0;
}
.view-ImageRollover .view-content { /* outer container */
position: relative;
}
.view-ImageRollover .field-content img { /* inner container */
display: block!Important;
float: left;
margin: 0;
padding: 0;
position: absolute;
top: 0px;
}
/* default image */
#upload {
float: left;
z-index: 5;
position: absolute;
}
#upload .imagefield-field_image img{
left:0px;
position: absolute;
}
Does anyone have an idea of what my issue is? let me know if im not clear. I tried adding display:block to the .imagefield but it gets over wridden by the jquery and won't go back to block.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意
,Jquery 允许您使用以下语法来定位元素值:
IMG[标题='某个值']
Give this a shot
note that Jquery allows you to locate element values using the following syntax:
IMG[title='somevalue']