Modify HTML element via JQuery functions

0
<div id="post-0" class="col-md-8 single-publicacoes">
    <div class="index">
        <div class="index-thumbnail">[IMAGE]</div>
        <div id="index-mascara">[EFEITO]</div>
        <div class="index-title-date">
            <p class="title-date">[TEXTO]</p>
        </div>
   </div>
</div>
<div id="post-1" class="col-md-8 single-publicacoes"> ...

Partial jQuery statement:

$(".title-date").on('mouseover', function(){

    // função

}).on('mouseleave', function(){

    // função

});

Since the mouseover and mouseleave functions, I can make the paragraph p.title-date modify the background of #index-mascara by remembering that it can modify only the current element and not the others?

    
asked by anonymous 21.07.2015 / 21:09

1 answer

1

Switch from:

<div id="index-mascara">[EFEITO]</div>

To:

<div class="index-mascara">[EFEITO]</div>

And to get to ".index-mascara" from ".title-date" use:

var mascara = jQuery(this).parent('.index-title-date').prev('.index-mascara');

Now that you have access to the element, just apply the actions you want.

    
21.07.2015 / 21:22