[jQuery] Re: Disable input button, using wrong HTML code?
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
[jQuery] Re: Disable input button, using wrong HTML code?
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
[jQuery] Re: Disable input button, using wrong HTML code?
Right. The disabled attribute takes an actual string, not a boolean. You can set even set it to true if you prefer: $(#button).attr(disabled,true); -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Jonathan Vanherpe (T T NV) Sent: Wednesday, May 06, 2009 9:35 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Disable input button, using wrong HTML code? 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
[jQuery] Re: Disable input button, using wrong HTML code?
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 (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. Jonathan -- Jonathan Vanherpe - Tallieu Tallieu NV - jonat...@tnt.be
[jQuery] Re: Disable input button, using wrong HTML code?
Even that still returns disabled= On May 6, 9:41 am, Andy Matthews li...@commadelimited.com wrote: Right. The disabled attribute takes an actual string, not a boolean. You can set even set it to true if you prefer: $(#button).attr(disabled,true); -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Jonathan Vanherpe (T T NV) Sent: Wednesday, May 06, 2009 9:35 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Disable input button, using wrong HTML code? 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
[jQuery] Re: Disable input button, using wrong HTML code?
On May 6, 9: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 (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. 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... Since I was also trying to use CSS to select disabled elements input=[disabled=disabled]{background:#EEE;} then I looked at the source with FireBug and Safari's Developers Toolkit with same results. But thanks for your help!
[jQuery] Re: Disable input button, using wrong HTML code?
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
[jQuery] Re: Disable input button, using wrong HTML code?
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.htmlcharset=(detect+automatically)doctype=Inlinegroup=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