>Is there another way to accomplish this?

$(".post").hover(function () {
        $(this).find('.category,.comments').show();
}, function () {
        $(this).find('.category,.comments').hide();
});




On Jul 13, 9:50 am, aakoch <outofthem...@gmail.com> wrote:
> I find it frustrating that the transversing add function (http://
> docs.jquery.com/Traversing/add) doesn't allow passing in a context
> like the jQuery function (http://docs.jquery.com/Core/
> jQuery#expressioncontext).
>
> Here's a use case: I want to select two different classes under the
> same element. Today I have to do:
> $(".post").hover(function () {
>     $(".category", this).show();
>     $(".comments", this).show();}, function () {
>
>     $(".category", this).hide();
>     $(".comments", this).hide();
>
> });
>
> or:
> $(".post").hover(function () {
>     $(".category", this).add($(".comments", this)).show();}, function () {
>
>     $(".category", this).add($(".comments", this)).hide();
>
> });
>
> I would rather have:
> $(".post").hover(function () {
>     $(".category", this).add(".comments", this).show();}, function () {
>
>     $(".category", this).add(".comments", this).hide();
>
> });
>
> Is there another way to accomplish this? (Well, I know this can be
> done with CSS, but this is just an example.)
>
> If not, can this functionality be added?
>
> Thanks,
> Adam

Reply via email to