我似乎无法让 removeAttr
工作,我正在使用我在 jQuery 网站上看到的示例.基本上 onclick
我添加属性来禁用一个字段(效果很好)但是当用户再次点击它应该启用有问题的字段.我使用警报来确保 else 块被触发,所以我知道不是这样.
I can't seem to get removeAttr
to work, I'm using the example I saw on the jQuery site. Basically onclick
I add the attribute to disable a field (which works just fine) but when the user clicks again it should enable the field in question. I used alerts to make sure the else block is being fired, so I know that's not it.
代码:
$('#WindowOpen').click(function (event) {
event.preventDefault();
$('#forgot_pw').slideToggle(600);
if('#forgot_pw') {
$('#login_uname, #login_pass').attr('disabled','disabled');
} else {
$('#login_uname, #login_pass').removeAttr('disabled');
}
});
谢谢.
都好用这个:
$('#WindowOpen').toggle(
function()
{
$('#login_uname, #login_pass').attr("disabled","disabled");
},
function()
{
$('#login_uname, #login_pass').removeAttr("disabled");
});
这篇关于jQuery删除属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!