Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select an image inside a link inside of a list-element with a class attribute with jquery?
    text
    copied!<p>I have following problem: I got a dynamically generated list of thumbnails where i can't give the images neither a class nor an id-attribut. The list looks like this:</p> <pre><code>&lt;div id="list"&gt; &lt;ul id="clips"&gt; &lt;li class="inactive"&gt;&lt;a href=""&gt;&lt;img src="http://farm4.staticflickr.com/3731/buddyicons/30470506@N05.jpg?1377890675#30470506@N05"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="inactive"&gt;&lt;a href=""&gt;&lt;img src="http://farm8.staticflickr.com/7406/9704752996_361b1f64a7_s.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="inactive"&gt;&lt;a href=""&gt;&lt;img src="http://farm6.staticflickr.com/5545/9703755774_818c649c7c_s.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="active"&gt;&lt;a href=""&gt;&lt;img src="http://farm3.staticflickr.com/2892/buddyicons/98149247@N02.jpg?1377034353#98149247@N02"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>As you can see has one list element the class attribute "active". i gave this one another style than the others. But i want the previous and the next picture to have different styles as well. Now is the question: How to select them?</p> <p>I was experimenting a bit and was able to select the previous and the next list element and could change their styles. The Code for it was:</p> <pre><code>&lt;script type="text/javascript" src="jquery-2.0.3.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $('li.active').prev().css('background-color', 'red'); $('li.active').prev().css('height', '300px'); $('li.active').next().css('background-color', 'red'); $('li.active').next().css('height', '300px'); }); &lt;/script&gt; </code></pre> <p>That worked for the list elements. But i need to select the images. Unfortunately "li.active img" didnt work and unfortunately i am not able to change the php-code so that the images will have a class name. So is there a way to select that two images and change their styles with jquery?</p> <p>Regards</p>
 

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