当我选择与父类的链接时,我尝试在浏览器中选择一个链接,如果此链接可用于子菜单:hasSubMenu我的问题是当我不想要一个链接时选择了很多链接...
<li style="z-index: 100;" class=""><a href="/#" class="hasSubMenu" style="background: none repeat scroll 0pt 0pt rgba(114, 130, 143, 0.17); color: rgb(68, 68, 68);">A propos<span class="subDown"></span></a><ul class="sub-menu" style="top: 32px; visibility: visible; left: 0px; width: 187px; display: none;"><li><a href="/contactez_nous.php" style="background-color: rgb(248, 196, 96); text-shadow: none; margin: 0pt; text-decoration: none; padding-left: 6px;">Contact</a></li><li><a href="/page.php?4" style="padding-left: 6px;">Mentions légales</a></li><li><a href="/page.php?5" style="padding-left: 6px;">Partenaires</a></li></ul><ul class="sub-menu" style="display: none; visibility: visible;"><li><a href="/contactez_nous.php" style="background-color: rgb(248, 196, 96); text-shadow: none; margin: 0pt; text-decoration: none;">Contact</a></li><li><a href="/page.php?4">Mentions légales</a></li><li><a href="/page.php?5">Partenaires</a></li></ul></li>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
var exploded = window.location.href.split('/');
// alert(exploded[3]);
$('ul.sub-menu li a').each(function(){
var items = $(this).attr('href');
var item_clean = items.substring(1, items.length);
if(item_clean == exploded[3]){
$(this).parents().find('a.hasSubMenu:first').attr('style','background: rgba(114, 130, 143, 0.17) none repeat scroll 0 0;color: #444444;');
$(this).attr('style','background-color:#F8C460;text-shadow:none;margin:0;text-decoration:none;');
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢你的回答
| 归档时间: |
|
| 查看次数: |
359 次 |
| 最近记录: |