How to manipulate an element with jQuery when they are at the same hierarchy level?

1
echo '<div class="servico">';
    ?><p class="servico_title opensans fw700 fs16"><?php the_title() ?></p><?php
    echo '<img src="'.UP.'/2015/08/enfeite_serv.jpg" width="100%" height="auto" class="enfeite_serv">';
    echo '<img src="'.UP.'/2015/08/arrow-down.jpg" class="chama_servico">';
    echo '<div class="servicos_the_content opensans fs14 fw400 white">'.content(18).'</div>';
echo '</div>';

I want through chama_servico to handle servicos_the_content . I started but I do not know how to finish.

jQuery(function($){     

    $(".chama_servico").on('click', function(){

        var atributo = jQuery(this).parent('.servico') ...

    });

});

I'm going to put a class active in servicos_the_content .

    
asked by anonymous 16.08.2015 / 21:43

1 answer

1

You can go up the DOM to .servico and then down to .servico_title . In this case you would use:

$(".chama_servico").on('click', function(){
    var atributo = $(this).closest('.servico').find('.servico_title').html();
});

I've used .html() as an example, to get the html of this% wrapper%.

    
16.08.2015 / 22:57