I think you're looking for filter not find. Try this:

$(function(){
    $("[EMAIL PROTECTED]").change(function(){
        $(".group").hide().filter("."+$(this).val()).show();
    }).val("us").change();
});

-blair

Jake McGraw wrote:
> Hey all, not sure if this is a bug, but I came across it today:
>
> Let's say my document looks like this:
>
> <ul>
>     <li>Pick a country
>        <select name="country">
>           <option value="us">United States</option>
>           <option value="gb">United Kingdom</option>
>           <option value="au">Australia</option>
>        </select>
>     </li>
>     <li class="group us">United States</li>
>     <li class="group us">United States</li>
>     <li class="group gb">United Kingdom</li>
>     <li class="group au">Australia</li>
> </ul>
>
> and my js looks like this:
>
> $(function(){
>     $("[EMAIL PROTECTED]").change(function(){
>        $(".group").hide().find("."+$(this).val()).show();
>     }).val("us").change();
> });
>
> What I've found is that jQuery won't "find" the jQuery objects when 
> chaining find(".class_name") to a group of jQuery objects already 
> selected by class. Hope that sentence made sense. This script will 
> work fine if I split up the show/hide into two calls, that is:
>
> $(".group").hide();
> $("."+$(this).val()).show();
>
> So, my question is, if find() will operate on elements of the same 
> level using element name or id ($("li").find(".group") returns all 
> li.group) why won't it work on elements of the same level when using 
> only class names ($(".group").find(".us") returns nothing)?
>
> - jake
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to