[英]Jquery addClass and removeClass onclick() not working on fontawesome
I am trying to change the fontawesome icon on a button when i click on it. 我尝试更改按钮上的fontawesome图标。 ie the button is in a table
即按钮在表格中
<tr>
<td> <a href="orders/view/5">#OID005</a></td>
<td> hfg</td>
<td> hhkh</td>
<td> 2015-09-26 16:31:49</td>
<td> 400</td>
<td><button id="#OID005" class="btn btn-info" onclick="work('#OID005','#OID005fa');">
<i id="#OID005fa" class="fa fa-files-o"></i> Take Order</button></td>
<tr>
Here is the JS file for that 这是那个的JS文件
function work(e,f){
$(f).removeClass('fa-files-o');
$(f).addClass('fa-spinner fa-pulse');
$(e).prop('disabled',true);
$('#damnit').slideToggle();
}
Why wont it change the icon? 为什么不更改图标?
Remove the #
in id 删除ID中的
#
<button id="OID005" class="btn btn-info" onclick="work('OID005','OID005fa');">
<i id="OID005fa" class="fa fa-files-o"></i> Take Order
</button>
and change you work()
like this, 然后像这样改变你的
work()
,
function work(e, f) {
$("#"+f).removeClass('fa-files-o');
$("#"+f).addClass('fa-spinner fa-pulse');
$("#"+e).prop('disabled', true);
$('#damnit').slideToggle();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.