Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery .prop("disabled", false) not working in Chrome

Tags:

jquery

prop

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

like image 855
user994461 Avatar asked Feb 11 '12 13:02

user994461


People also ask

How to disable false in jQuery?

An element can be disabled in HTML by setting disable property to true and enabled again by setting disabled=false. By using jQuery, you can grab the element you want to enable or disable and change this property by using the prop() or attr() function, depending upon the version of jQuery you are using.

How to add disabled attribute in jQuery?

We can easily disable input box(textbox,textarea) using disable attribute to “disabled”. $('elementname'). attr('disabled','disabled'); To enable disabled element we need to remove “disabled” attribute from this element.

How to enable disable input JavaScript?

document. getElementById('element-name'). disabled=false; was what I was looking for. Thanks!

How check textbox is enabled or disabled in jQuery?

You can use $(":disabled") to select all disabled items in the current context. To determine whether a single item is disabled you can use $("#textbox1").is(":disabled") . Save this answer.


2 Answers

Remove the attribute:

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

See .removeAttr() for more details

like image 178
J. Holmes Avatar answered Sep 17 '22 14:09

J. Holmes


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.

like image 21
Fiddles Avatar answered Sep 17 '22 14:09

Fiddles