将类添加到设置为“#”的href [英] Add a class to a href that's set to '#'

查看:86
本文介绍了将类添加到设置为“#”的href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有自动将类添加到任何设置为哈希值的HREF(#)?

Is there anyway to automatically add a class to any HREF that is set to a hash (#)?

我在Concrete5中使用自动菜单所以可以'不幸的是,它只是硬代码。

I am using an auto menu in Concrete5 so can't just hard code it in unfortunately.

我会猜测并说它将是必须使用的JavaScript / jQuery?

I'm going to take a guess and say that it will be JavaScript/jQuery that will have to be used?

提前致谢!

推荐答案

这样做,

$('a[href="#"]').addClass('className');

在上面的代码中,我们使用了 属性等于选择器

Here in the above code we have used attribute equals selector.

这篇关于将类添加到设置为“#”的href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆