[英]catching anchor in ul li with jquery
This is my menu portion of the site. 这是我网站的菜单部分。
this is defined in _Layout.cshtml() page. 这是在_Layout.cshtml()页面中定义的。
when Neu Gesellschaft
page is loaded, i want to change css
of the anchor a
. 加载
Neu Gesellschaft
页面时,我想更改锚点a
css
。 In order to do so, i have tried following jquery code. 为了做到这一点,我尝试了以下jQuery代码。
$('ul#menu li a#mnuNG').removeClass();
$('ul#menu li a#mnuNG').addClass("menuitem-active");
But its not working. 但是它不起作用。 I think, i have failed to catch the anchor
a
. 我认为,我未能抓住锚点
a
。 I have used F12
in IE10
. 我在
IE10
使用了F12
。 New styles are not implented anyway. 无论如何,新风格都不容忍。 Any suggestion would be helpful.
任何建议都会有所帮助。
if needed, my menuitem-active
class : 如果需要,我的
menuitem-active
类:
.menuitem-active
{
background:#000000 !important;
color:#fff !important;
text-decoration:underline !important;
}
Don't know how it happens! 不知道怎么回事! but I found the problem and solved it.
但我发现了问题并解决了。 The problem was the
id
of the anchor tag a
. 问题是
anchor tag a
的id
。 It generates a faulty href
which prevents the page from redirection and many other jquery implementation. 它生成错误的
href
,阻止页面重定向和许多其他jquery实现。
I just removed id
from <a>
and applied following code. 我刚刚从
<a>
删除了id
并应用了以下代码。 And it worked fine. 而且效果很好。
$('#li1 a').removeClass().addClass("menuitem-active");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.