Hi Philip,
Perhaps the MoreSelectors plugin will help you:
http://www.softwareunity.com/sandbox/JQueryMoreSelectors/
The ":option-def" selector may be what you need to find option elements that
were selected by default (when page loaded).
Does that help?
George
GreyCells wrote:
>
> Thanks George
>
> I think the '@selected' is looking for the option that was set when the
> form was initially rendered (although, obviously, I'm not that well
> aquainted with JQuery yet). I'm after the optgroup label for the option
> selected after the user has picked a new value: As an example:
>
> OptGroup 1
> - Option1.1
> - Option1.2
> OptGroup2
> - Option2.1
> - Option2.2
>
> If Option1.1 is selected when the form is rendered, then I'd like to get
> '(OptGroup1)' displayed to the right of the select list. If the user then
> changes the selection to Option2.2, I'd like to display ('(OptGroup2)' to
> the right of the select list.
>
> ~Philip
>
>
> George Adamson wrote:
>>
>> I hope I've understood this correctly.
>> Perhaps try something along the lines of this in the function (not
>> tested)...
>>
>> var myOptGrpLabel =
>> $(this).find("[EMAIL PROTECTED]").parents("OPTGROUP").attr("label");
>> /* ... do something with myOptGrpLabel... */
>>
>> The parents("OPTGROUP") could be overkill, maybe just .parent() is enough
>> if you're sure the option elements are in an optgroup.
>>
>> George
>>
>>
>>
>> GreyCells wrote:
>>>
>>> I'd like to be able to display the optgroup label attribute value after
>>> a select list is changed. This is what I have so far, but I think I'm
>>> heading down the wrong track, because a) I want the optgroup label
>>> value, not the selected option value and b) I don't want to keep
>>> appending if the user changes the selection more than once...
>>>
>>> $(document).ready(function() {
>>> $('#MySelect').change( function() {
>>> $('#MySelect').after('('+$('#MySelect').val()+')');
>>> } ) ;
>>> });
>>>
>>> Any help would be appreciated :)
>>>
>>> ~Philip
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Getting-the-optgroup-for-a-select-option-tf3023854.html#a8407347
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/