logo       

[jQuery] Re: Selecting a child of 'this': msg#00499

jQuery

Subject: [jQuery] Re: Selecting a child of 'this'


$(this).find(".child").show()

On Mar 4, 12:50 am, schickb <schi...@xxxxxxxxx> wrote:
> I'd like to apply a css effect to a child upon hovering over its
> parent. Both are block level elements. The trick is that there is a
> list of these and I only want to modify one at a time. I've got
> something that works, but it feels a bit ugly:
>
>     $("#parent").hover(
>         function(){
>                 // This is the line in question.
>                 $('#' + this.id + ' .child').show();
>         },
>         function(){
>                 // Hide them all
>                 $('.child').hide();
>         }
>     );
>
> I could use Ids on the children that are derived from their parents,
> but that doesn't seem any cleaner. Is there a better way to handle
> this?

Google Custom Search

News | Mail Home | sitemap | FAQ | advertise