如何通过jQuery在针对特定URL的页面上添加类?
发布于 2010-08-19 16:35:19
我假设你想添加一个链接到所有有特定href值的锚标签?
您可以使用以下内容按href属性筛选a标记匹配项:
$('a[href="http://www.google.com"]').addClass("className");发布于 2010-08-19 17:38:35
要么是GenericTypeTea的答案
或
$('a').each(function() {
    if($(this).attr('href') == 'http://www.google.com') {
        $(this).addClass('className');
    }
});https://stackoverflow.com/questions/3519871
复制相似问题