Note that there are some explanatory texts on larger screens.

plurals
  1. POOnly approach child element with certain class
    primarykey
    data
    text
    <p>I'm trying to get elements with a certain class from a list.</p> <p>I roughly have the following html</p> <p><pre><code> &lt;ul id="list"> &lt;li class="1"> &lt;div class="container"> &lt;div class="left"> &lt;a href=""> &lt;div class="text"> &lt;p>Some text&lt;/p> &lt;/div> &lt;div class="image"> &lt;img> &lt;/div> &lt;/a> &lt;/div> &lt;div class="right"> &lt;p>Some more&lt;/p> &lt;/div> &lt;/div> &lt;/li> &lt;li class="2"> &lt;div class="container"> &lt;div class="left"> &lt;a href=""> &lt;div class="text"> &lt;p>Some text&lt;/p> &lt;/div> &lt;div class="image"> &lt;img> &lt;/div> &lt;/a> &lt;/div> &lt;div class="right"> &lt;p>Some more&lt;/p> &lt;/div> &lt;/div> &lt;/li> &lt;li class="3"> &lt;div class="container"> &lt;div class="left"> &lt;a href=""> &lt;div class="text"> &lt;p>Some text&lt;/p> &lt;/div> &lt;div class="image"> &lt;img> &lt;/div> &lt;/a> &lt;/div> &lt;div class="right"> &lt;p>Some more&lt;/p> &lt;/div> &lt;/div> &lt;/li> &lt;/ul> </pre></code></p> <p>Now i want to do change some classes on hover which only affect the elements that are children of the hovered element, but i can't get it working. So far i tried the following (all without the desired result):</p> <p><pre><code> $('ul#list li').hover(function(){ // remove all previous active classes $(this).each('.text').removeClass('active');</p> <pre><code>// add active class to current item $(this).children('.text').addClass('active'); $(this).next('.text').addClass('active'); $(this).closest('.text').addClass('active'); </code></pre> <p>}); </pre></code></p> <p>Does anybody has an idea how to approach this because i'm out..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload