-4

This is my Code sample

<button id="action-save" class="button-primary">Save Details</button>

how to disable this button?

I tried like value = "disabled" it doesn't worked out well

sundar rajan
  • 61
  • 2
  • 10

2 Answers2

2

Just add disabled?

<button id="action-save" class="button-primary" disabled>Save Details</button>
nicael
  • 17,612
  • 12
  • 55
  • 87
  • its a real pain when people dont give a reason for downvoting – Sam Denton Jul 03 '14 at 14:47
  • 1
    I've upvoted it as it's right. No idea why it was downvoted. `disabled='disabled'` is only necessary in `xhtml`, which this is not. So `disabled` alone is fine. – Albzi Jul 03 '14 at 14:50
2

Use HTML property:

disabled="disabled"

or just

disabled

So your HTML tag would look like this:

<button id="action-save" class="button-primary" disabled="disabled">Save Details</button>

or

<button id="action-save" class="button-primary" disabled>Save Details</button>

This will make the element unclickable/unselectable.

Hope this helps!!!

Satwik Nadkarny
  • 4,944
  • 2
  • 22
  • 40
  • 1
    You don't need to do `disabled="disabled"`. You can just type `disabled`. – Albzi Jul 03 '14 at 14:48
  • 1
    @BeatAlex I have had some browser issues when using just disabled. But that was quite some time ago. So I always prefer to use disabled="disabled". Ah, but that could have just become my habit now. SO I've edited my answer to include both the ways. – Satwik Nadkarny Jul 03 '14 at 14:53
  • Sweet, I've +1'd you too :) – Albzi Jul 03 '14 at 14:54