On May 7, 12:46 am, "Jonathan Vanherpe (T & T NV)" <jonat...@tnt.be>
wrote:
> Stephen Korecky wrote:
> > I tried that too, has same results...
>
> > On May 6, 9:35 am, "Jonathan Vanherpe (T & T NV)" <jonat...@tnt.be>
> > wrote:
> >> stephen wrote:
> >>> I created a test page
> >>> here:http://clients.stephenkorecky.com/stephen_korecky/js_test.html
> >>> But basically the problem is that $("#button").attr("disabled",true);
> >>> should disable a input button, and it does, HOWEVER it outputs
> >>> disabled="" when it should output disabled="disabled" anyone know how
> >>> to fix this?
> >> $("#button").attr("disabled","disabled");
> >> --
> >> Jonathan Vanherpe - Tallieu & Tallieu NV - jonat...@tnt.be
>
> If you're talking about what you see in Firebug:
> this just shows Gecko's internal DOM tree, which isn't necessarily the
> same as how the w3c would like it to be. If you change your html to be
> <input .... disabled="disabled" />, you'll see that firebug will drop
> the value too.
>
> Most browsers just ignore the value of disabled and just look at the
> existence of the attribute
Probably because that is what the HTML specification tells them to
do. :-)
The OP has an XHTML doctype, but is serving the document as text/
html. The document is treated as HTML, any attempt to set a value for
the disabled attribute is ignored as junk. The presence of the
attribute is sufficient to disable the element.
The document isn't valid XHTML anyway:
<URL:
http://validator.w3.org/check?uri=http%3A%2F%2Fclients.stephenkorecky.com%2Fstephen_korecky%2Fjs_test.html&charset=(detect+automatically)&doctype=Inline&group=0
>
> (which you'll have to keep in mind when you
> use jquery to reenable the button, you'll need to remove the attribute,
> not just set it to false). the 'correct' way is disabled="disabled", though.
"Correct" if that is being done in XHMLT markup, but not through DOM.
If setAttribute could be relied upon, and you were in fact dealing
with an XML document, the "correct" way would be:
element.setAttribute('disabled', 'disabled');
However, setAttribute is broken in some browsers and therefore should
be avoided in HTML documents. The simplest, cross-browser way is to
set the DOM property to true or false.
--
Rob