On May 6, 2009, at 10:59 AM, Stephen Korecky wrote:

On May 6, 9:46 am, "Jonathan Vanherpe (T & T NV)" <jonat...@tnt.be>
wrote:
 the 'correct' way is disabled="disabled", though.

Jonathan
--
Jonathan Vanherpe - Tallieu & Tallieu NV - jonat...@tnt.be


Ah, that makes more sense then, I know the 'correct' way is
disabled="disabled" which is why I was confused as to why this was
even working...

If I'm understanding things correctly, the "correct" value for the HTML attribute is "disabled," but for the DOM property, which is what you're really setting with JavaScript, the "correct" value is a Boolean.

If you look in the jQuery core, you'll see that it checks for a true/ false value for the :disabled and :enabled selectors:

        filters: {
                enabled: function(elem){
                        return elem.disabled === false && elem.type !== 
"hidden";
                },
                disabled: function(elem){
                        return elem.disabled === true;
                },

                // and so on
        }

also see:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-642250288
http://msdn.microsoft.com/en-us/library/ms533732(VS.85).aspx

In any case, both .attr('disabled', true) and .attr('disabled, 'disabled') should work.


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to