问题描述
我使用jQuery,我需要使一些锚标签不执行任何操作。
我通常会这样写:
< a href =#>连结< / a>
然而,这指的是页面的顶部!
如果你不想指向任何东西,你可能不应该使用< a> $ c $如果你想看起来像一个链接,但不像一个链接,最好是使用适当的元素(如<$ <$> $)。
< span class =fake-linkid =fake-link-1>我是链接吗?< / span>
.fake-link {
color:blue;
text-decoration:下划线;
光标:指针;
}
另外,假设你标记了这个问题jQuery你想附加一个点击事件手柄。如果是这样,只要做与上述相同的事情,然后使用类似下面的JavaScript:
$('#fake-link点击(函数(){
/ *把你的代码放在这里* /
});
I use jQuery, I need to make some anchor tags perform no action.
I usually write it like this:
<a href="#">link</a>
However this refers to the top of the page!
If you don't want to have it point to anything, you probably shouldn't be using the <a>
(anchor) tag.
If you want something to look like a link but not act like a link, it's best to use the appropriate element (such as <span>
) and then style it using CSS:
<span class="fake-link" id="fake-link-1">Am I a link?</span>
.fake-link {
color: blue;
text-decoration: underline;
cursor: pointer;
}
Also, given that you tagged this question "jQuery", I am assuming that you want to attach a click event hander. If so, just do the same thing as above and then use something like the following JavaScript:
$('#fake-link-1').click(function() {
/* put your code here */
});
这篇关于如何制作锚标签没有提及?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!