显示类而不是 ID (jQuery)
<a href="#tab1">Tab1</a>
<div id="tab1">content</a>
...
var a = $(this).attr('href');
$(a).show();
这有效,但仅当容器具有 ID 时,因为锚链接以“#”开头,我如何使其与类一起工作,以便它识别
content
?非常感谢
<a href="#tab1">Tab1</a>
<div id="tab1">content</a>
...
var a = $(this).attr('href');
$(a).show();
This works but only if the container has an ID since the anchor link starts with "#", how do I make it work with a class, so that it recognized <div class="tab1">content</a>
?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jsFiddle。
如果您是正则表达式(但是我不会在这里使用它),您可以使用...
jsFiddle。
jsFiddle.
If your a regex'r (I wouldn't use it here, however), you could use...
jsFiddle.