When I use .prop ('disabled', true) to disable the button, it works, but the button does not look disabled. I remember in the old days when I used .attr ('disabled', 'disabled') to disable buttons, they will become more noticeably disabled, i.e. The text will be grayed out or something else, so the user will not try to click. Now I think that the border of the button disappears a little, but the text is missing.
What is the easiest way to get your behavior back? I am lazy and do not want to write one line of code to disable this button, and the other to disable it - I want, if possible, to get both effects in one command. Should I use a different element than the button? Another way to disconnect?
I made a fiddle here: http://jsfiddle.net/ak2MG/ . Here is the code.
HTML:
<button type='button' id='mybutton'>Click Me</button>
<div id="mydiv"></div>
JavaScript:
$('#mybutton').click( function() {
$('#mydiv').append("<p>Button was clicked.</p>");
$('#mybutton').prop('disabled',true); } );
source
share