Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
102 views
Welcome To Ask or Share your Answers For Others

1 Answer

All good used this:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...