我在尝试向我的链接添加活动状态时遇到了一些问题。这个我摆弄代码:单击时将活动状态添加到超链接
$(function() {
$('a').click(function() {
$(this).addClass('PnavCurrent');
//$("div a").removeClass("PnavCurrent");
//$("div a[href="+newHash+"]").addClass("PnavCurrent");
$(this).removeClass('PnavCurrent');
$(this).css('color', '#51ad9d');
$(this).css('z-index', '2');
$(this).css('border-color', '#00a8ff');
$('a').hover($(this).css('z-index', '10'));
});
});
出于某种原因,它不会对链接应用CSS活动状态类(“PnavCurrent”),但是当我在脚本代码指定它它不正常工作{$(this).css...}
。现在我想的是,在添加一个悬停状态的z-index在脚本代码的链接,这样的事情:
$('a').hover($(this).css ('z-index', '10'));
我试图使用的代码有点堵在上面努力实现这一目标但它不起作用。我将不胜感激,如果任何人都可以提供帮助,并可能是一个更好的解决方案。
您正在添加,然后删除班级'PnavCurrent' – 2012-07-20 01:05:37