带有onclick事件设置的字体真棒图标 [英] Font-Awesome icon with an onclick event set
问题描述
我正尝试使用以下font-awesome icon
I am trying to use the following font-awesome icon
<i class="fa fa-minus-circle"></i>
作为我页面上列表中项目旁边的删除图标,如下所示:
as a delete icon next to items in a list on my page like this:
Item 1 delete-icon
Item 2 delete-icon
点击其中一个图标,我需要运行一个JavaScript函数...
On click of one of these icons I need to run a JavaScript function...
我应该使用什么html元素包裹图标?我注意到,当我使用锚标签时,它变成蓝色,当我使用按钮时,它最终被包裹在一个按钮中。有没有其他的选择?
What html element should I be wrapping the icon with? I noticed that when I use an anchor tag it turns blue and when I use a button it ends up being wrapped in a button. Are there any other options?
基本上我想这样做
<a onclick="Remove()"><i class="fa fa-minus-circle"></i></a>
或这个
<button onclick="Remove()"><i class="fa fa-minus-circle"></i></button>
但没有任何修改只会显示图标。没有蓝色,也没有包裹在按钮中。
But have only the icon appear as is with no modifications. No blue color, and not wrapped inside a button.
推荐答案
只需使用 div
标记或 span 标记<
<div onclick="myFunction()">
<i class="fa fa-minus-circle"></i>
</div>
或
<span onclick="myFunction()">
<i class="fa fa-minus-circle"></i>
</span>
这篇关于带有onclick事件设置的字体真棒图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!