Re: [jQuery] Checking select option has class?
Hi all, :disabled doesn't want to work as I expect - when I submit with a disabled option selected, the whole select drop down becomes disabled (or rather the class is added to ALL the options). I've added my real code in below, rather than working with hypotheticals - any more ideas? // if option is disabled, don't submit it if( $('#idol_date_day1').is(:checked) $('#idol_datetime_day1 option:disabled') ){ // add class to change colour $('#idol_datetime_day1 option:disabled').addClass(required).get(0).focus(); return false; }else{ $('#idol_datetime_day1 option:disabled').removeClass(required); } Thanks, Luc -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dave Methvin Sent: 18 October 2006 17:54 To: 'jQuery Discussion.' Subject: Re: [jQuery] Checking select option has class? $('#myselect option').is(:disabled).addClass('disabled'); .is() isn't chainable, but you can just add :disabled to the selector: $('#myselect option:disabled').addClass('disabled'); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ In2 Thames House Mere Park Dedmere Road Marlow Bucks SL7 1PB Tel 01628 899700 Fax 01628 899701 e: [EMAIL PROTECTED] i: www.in2.co.uk This message (and any associated files) is intended only for the use of discuss@jquery.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not discuss@jquery.com you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author [EMAIL PROTECTED] and do not necessarily represent those of the company. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Checking select option has class?
Luc Pestille schreef: // add class to change colour $('#idol_datetime_day1 option:disabled').addClass(required).get(0).focus(); change to $('#idol_datetime_day1 option:disabled').addClass(required).eq(0).focus(); This seems to be a common mistake. Maybe on one of the learning sites or on the documentation page of jquery.com there should be a list of common mistakes found in the mailing list to guide newcomers and even 'veterans' :). -- David Duymelinck [EMAIL PROTECTED] ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Checking select option has class?
Hi all, Thanks to IE's wonderful ommission of disabled="disabled" for options in select drop downs, I need to add a class to disabled options and and check for that class when the form is submitted. How doI check the selected option has a class within a select? if($('#myselect').get(0).hasClass("disabled") ){ //don't submit the form } ??? TIA. Luc PestilleWeb Designer e: [EMAIL PROTECTED]t: +44 (0)1628 899 700f: +44 (0)1628 899 701 In2Thames HouseMere ParkDedmere RoadMarlowBucksSL7 1PBTel 01628 899700Fax 01628 899701e: [EMAIL PROTECTED]i: www.in2.co.ukThis message (and any associated files) is intended only for the use of discuss@jquery.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not discuss@jquery.com you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author [EMAIL PROTECTED] and do not necessarily represent those of the company. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Checking select option has class?
Nope, that didn't work - I suspect (read:complete guess)because #myselect is the select element itself, not the option within it. Anyone else offer a solution? if($('#myselect').is(":disabled") ){ //don't submit the form } From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sam CollettSent: 18 October 2006 17:07To: jQuery Discussion.Subject: Re: [jQuery] Checking select option has class? On 18/10/06, Luc Pestille [EMAIL PROTECTED] wrote: Hi all, Thanks to IE's wonderful ommission of disabled="disabled" for options in select drop downs, I need to add a class to disabled options and and check for that class when the form is submitted. How doI check the selected option has a class within a select? if($('#myselect').get(0).hasClass("disabled") ){ //don't submit the form } ??? TIA. Luc PestilleWeb Designer e: [EMAIL PROTECTED]t: +44 (0)1628 899 700f: +44 (0)1628 899 701 In2Thames HouseMere ParkDedmere RoadMarlowBucksSL7 1PBTel 01628 899700Fax 01628 899701e: [EMAIL PROTECTED]i: www.in2.co.ukThis message (and any associated files) is intended only for the use of discuss@jquery.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not discuss@jquery.com you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author [EMAIL PROTECTED] and do not necessarily represent those of the company. ___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/I think this should work: if($('#myselect').is(":disabled") ){ //don't submit the form } ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Checking select option has class?
Luc Pestille schrieb: Nope, that didn't work - I suspect (read:complete guess) because #myselect is the select element itself, not the option within it. Anyone else offer a solution? if ( $('#myselect').is(:disabled) ){ //don't submit the form } $('#myselect option').is(:disabled).addClass('disabled'); -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/