有两个单选按钮和一个超链接。 如果选择“radiobutton1”,则启用超链接。 如果选择“radiobutton2”,则禁用超链接。 我可以使用jQuery来禁用超链接,但无法启用它。 如何使用jQuery启用超链接?
$("#hyperlink1").click(function(){
// return true or false based on your radio buttons
return enableLink;
});
如果要禁用超链接,您可以添加一个 onclick 处理程序并返回 false;
代码示例如下:
$("#radioDisable").click(function() {
$(“hyperlink”).click(function(){
return false;
});
$(“hyperlink”).addClass(“disabled”);
});
$("#radioEnable").click(function() {
$(“hyperlink”).click(function(){
return true;
});
$(“hyperlink”).removeClass(“disabled”);
});
可以获取和设置“disabled”属性。但是,此属性仅适用于单个对象,而不适用于对象集合。
if (!$("#ContinueButton")[0].disabled) {
UserContinue();
}
编写:
$("#ContinueButton")[0].disabled = !canContinue;