Question

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

Was it helpful?

Solution

Remove the attribute:

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

See .removeAttr() for more details

OTHER TIPS

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.

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.


Try to write it like that:

$('myButton').prop("disabled", "");

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(); });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top