April 14, 2012

How can I "remove" the disabled attribute on click?

Question by Strawberry

I couldn’t quite get it to work properly. I’m trying to remove the disabled attribute on click so that I can edit it.

My jQuery:

$('#edit-credentials').click(function() { 
    $('#credentials :input').prop("disabled", !$('#credentials:input').prop("disabled")) 
});

HTML:

<a id="edit-credentials" onclick="return false;" href="#">edit</a>

<div id="credentials">
<input disabled="disabled">
<input disabled="disabled">
</div>

Answer by Starx

What wrong with

$('#credentials :input').prop("disabled", false);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!