19

having problems with .prop("disabled", false) it's works fine in opera and firefox but IE and chrome i can't get it to work..

Actualy it's a invination form and im make send button like this

<input id="sendInvite" class="mail_send" disabled="disabled" type="button" name="invite" value="Send">

and here is css

.mail_send[disabled="disabled"] {background-color:#343434; color:#747474}

So as you can see button is disabled and you can't click, you must first write your name and mail after that button is remove disabled and you can send mail. For this im write code here is: http://pastebin.com/8u23G90b

But something is wrong here, in chrome and IE disabled never removed from button, im also load jquery 1.7.1

p.s sorry for my english

user994461
  • 495
  • 1
  • 4
  • 15

5 Answers5

23

Remove the attribute:

$('button').removeAttr("disabled");

See .removeAttr() for more details

J. Holmes
  • 17,946
  • 5
  • 43
  • 51
  • I [just tried](http://jsfiddle.net/frZ63/1/) both method in chrome 17, and they both work. I think your problem may lie else where, are you getting any errors on the console? – J. Holmes Feb 11 '12 at 13:54
  • interesting.. works also for me on chrome 16 on jsfiddle, on site don't work..there is no error in console. hmm.. – user994461 Feb 11 '12 at 14:10
2

Your problem is not with JQuery, but with your CSS selectors. The disabled attribute is referring to the default value when the page first loads, rather than whether the element is actually disabled or not.

The CSS selector you want is the :disabled selector:

.mail_send:disabled {background-color:#343434; color:#747474}

You can see an example with this jsfiddle.

Fiddles
  • 2,511
  • 1
  • 26
  • 34
0

I was running into a similar issue where I was using .prop("disabled", false) to remove disabled from a 'Save' button. Disabled was being assigned via .prop("disabled", true).

But wait who what - when trying to remove this property (which would be rendered as disabled in the html tag) I discovered that it was being output as class="disabled"!

For this - i used .removeClass('disabled') All i'm trying to say is if things don't work the way you think they should, make sure their initial output is what you'd expect.


DGG
  • 306
  • 3
  • 11
-1

Try to write it like that:

$('myButton').prop("disabled", "");
Julien Pires
  • 482
  • 7
  • 17
-1

just use button and live:

<button class="sendm">Send Email</button>

$(".sendm").live("click", function(e){
   var field1 = $("").val();
   var field2 = $("").val();

   if(field1 === "" || field2 === "" ){
    /// fake checker, you make this more robust etc
     return false;  // maybe do an alert here
   } else {
      //post form data and get json response
   }

});

 $(document).ready(function(){ $(".sendm").button(); });
davethecoder
  • 3,696
  • 4
  • 32
  • 64