jQuery-根据条件禁用和启用锚标记 [英] jQuery - disable and enable an anchor tag based on condition
本文介绍了jQuery-根据条件禁用和启用锚标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在页面加载中,我正在检查是否有人注册.如果是,那么我将启用一个链接,否则将禁用该链接.
On page load, I am checking to see if a person is registered. If he is then, I will enable a link otherwise disable the link.
我尝试了以下方法,但是它不起作用.
I tried the following , but it doesnt work.
var status = $('#status');
if (status == 'Registered'){
$('#addlink').data('disabled');
}
else {
}
推荐答案
基于CSS的替代方案是
An alternative based on CSS would be
$('#addlink').css('pointer-events', 'none');
截至2017年初,CanIUse报告对此功能的支持度为94%.
CanIUse reports a 94% support of this feature as of early 2017.
这篇关于jQuery-根据条件禁用和启用锚标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文