jQuery的删除属性 [英] jQuery remove attribute

查看:76
本文介绍了jQuery的删除属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法获得 removeAttr 来的工作,我用我的jQuery的网站上看到的例子。基本上的onclick 我添加禁用某个字段属性(工作得很好),但是当用户再次点击它应使有问题的领域。我用的警报,以确保其他块被解雇,所以我知道这不是它。

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.

code:

$('#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');
  }
});

感谢。

推荐答案

使用所有这一切都很好:

All good used this:

$('#WindowOpen').toggle(
    function()
    {
        $('#login_uname, #login_pass').attr("disabled","disabled");     
    },
    function()
    {
        $('#login_uname, #login_pass').removeAttr("disabled");      
    });

这篇关于jQuery的删除属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆