Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery adding and removing 'active' classes plus hover
    primarykey
    data
    text
    <p>I have a definition list with thumbnails. They are 50% opacity with a 'thumb' class. When hovered 100% opacity. When clicked 100% opacity plus change 'thumb' to 'thumbactive' class</p> <p>So far my crappy code works, only thing is I can not get the tn on 100% on click.</p> <pre> dl { width: 700px; } dt { clear: left; float: right; width: 400px; height:80px; margin: 0 0 10px 0; background:orange; } dd.thumb, dd.thumbActive { clear: none; float: left; margin: 0 0 10px 0; background:black; } dd { clear: right; } </pre> <pre> jQuery.noConflict(); jQuery(document).ready(function() { /* just for debugging */ function showClassNames() { jQuery("dt").each(function() { var className = jQuery(this).next().attr('class'); jQuery(this).text(className); }); }; showClassNames(); /* resets all thumbs (50% alpha, .thumb classname) */ function resetThumbs() { jQuery("dd").each(function() { jQuery(this).removeClass("thumbActive"); jQuery(this).addClass("thumb"); jQuery("dd img").css('opacity', 0.5); }); }; // half opacity for all thumbs except the first one (active) jQuery("dd:not(.thumbActive) img").css('opacity', 0.5); jQuery("dd img").hover( function() { jQuery(this).css('opacity', 1.0); }, function() { jQuery(this).css('opacity', 0.5); } ); jQuery("a.thumbClick").click(function() { resetThumbs(); jQuery(this).parent().removeClass("thumb"); jQuery(this).parent().addClass("thumbActive"); jQuery(this).css('opacity', 1.0); showClassNames(); return false; }); }); // end document ready </pre> <pre><code>&lt;div id="album-canvas-left" style="width:930px; " &gt; &lt;dl id="thumb-list" &gt; &lt;dt&gt;&lt;/dt&gt; &lt;dd class="thumbActive"&gt;&lt;a href="#" class="thumbClick"&gt;&lt;img src="gallery/album1/thumb/001.jpg" width="120" height="80" alt="living room" title="living room" /&gt;&lt;/a&gt;&lt;/dd&gt; &lt;dd&gt;&lt;/dd&gt; &lt;dt&gt;&lt;/dt&gt; &lt;dd class="thumb"&gt;&lt;a href="#" class="thumbClick"&gt;&lt;img src="gallery/album1/thumb/002.jpg" width="120" height="80" alt="bedroom" title="bedroom" /&gt;&lt;/a&gt;&lt;/dd&gt; &lt;dd&gt;&lt;/dd&gt; &lt;dt&gt;&lt;/dt&gt; &lt;dd class="thumb"&gt;&lt;a href="#" class="thumbClick"&gt;&lt;img src="gallery/album1/thumb/003.jpg" width="120" height="80" alt="kitchen" title="kitchen" /&gt;&lt;/a&gt;&lt;/dd&gt; &lt;dd&gt;&lt;/dd&gt; &lt;/dl&gt; </code></pre> <p></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.
    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