Within your click function, "this" refers to the element that was clicked
(in this case, either #bridge1 or #bridge2). You can then get the
(immediate) children of that element that match the selector 'p' and toggle
that.

$('#bridge1,#bridge2').click(function(){
       $(this).children('p').toggle();
       return false;
});

--
Hector


On Wed, Jul 29, 2009 at 1:23 PM, lukas <animod...@gmail.com> wrote:

>
> How can I pick an id element (here #bridge1,#bridge2) and toggle its
> child (here a p element) without actually using the id element as
> parent?
> 'this > p' apparently does not work.
>
> $('#bridge1,#bridge2').click(function(){
>        $('this > p').toggle();
>        return false;
> });
>
> Thanks for your help!

Reply via email to