Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see you're using jQuery (and have edited your question accordingly).</p> <p>With jQuery, it's really easy to get a list of matching elements using CSS syntax:</p> <pre><code>var list = $('#parentId &gt; .selected'); </code></pre> <p>That gets a list of the direct children of the element with the ID "parentId" that have the class "selected". You can then do things with them, such as:</p> <pre><code>list.removeClass("selected"); </code></pre> <p>Then add "selected" to the element you want to select.</p> <p><strong>Edit</strong> I think this should do it:</p> <pre><code>$(thumbs).click(function() { // Remove selected class from any elements other than this var clicked, previous; clicked = $(this); if (!clicked.hasClass(clickedClass)) { previous = $(thumbs+'.'+clickedClass); previous.removeClass(clickedClass).fadeTo(fadeTime, inactiveOpacity); clicked.addClass(clickedClass).fadeTo(fadeTime, activeOpacity); } }); </code></pre> <p>I'm assuming there that the "selected" class isn't necessary for the fade effect to look right.</p> <p>Note how the above will completely ignore the click if the clicked element already has the class. If you don't want that, remove the <code>hasClass</code> check and add <code>.not(clicked)</code> to the end of the <code>previous = $(thumbs+'.'+clickedClass)</code> line, but I don't know what your fade in would do at that point if you've already done it once.</p> <p>I'm not getting the hover stuff; I thought you wanted this to happen on click, not hover.</p>
    singulars
    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.
 

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