Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the difference between prop('disabled','disabled') and prop('disabled',true)

Tags:

jquery

Im using jQuery to disable an option in a select drop down list. I need to know the difference between using

prop('disabled','disabled')

and

prop('disabled',true)

Both pretty much work on all browsers (not sure if I've missed any tho), but on another post I was he say use disable, true. Can someone please elabarate? Thanks

like image 936
nasty Avatar asked Aug 03 '12 07:08

nasty


People also ask

What is disabled property in javascript?

The disabled property sets or returns whether a drop-down list should be disabled, or not. A disabled element is unusable and un-clickable. Disabled elements are usually rendered in gray by default in browsers. This property reflects the HTML disabled attribute.

How to disable and enable a tag in jQuery?

The disable/enable an input element in jQuery can be done by using prop() method. The prop() method is used to set or return properties and values for the selected elements. Example 1: This example uses prop() method to disable the input text field.

How to disable jQuery function?

Add one variable like isDisabled = false; Check that variable at the begining of the MyFunction(). And set that variable to true when #x clicked.

How to disable the div in jQuery?

Using jQuery The idea is to disable click events inside div with jQuery and CSS. This can be done by setting pointer-events CSS property with the help of jQuery's . addClass() function.


1 Answers

According to the W3C forms specification, the disabled attribute is a boolean attribute,

so prop('disabled',true) is right.

prop('disabled','disabled') also works because the string 'disabled' evaluates to true.

like image 142
xdazz Avatar answered Sep 30 '22 14:09

xdazz