jquery - showing post description fading in on hover -


right have following code set up:

$(function() {     $('.thumbnail').mouseenter(function() {         $('.thumbnail').fadeout(200, function() {             $('.description').fadein(200);         });     });     $('.description').mouseleave(function() {         $('.description').fadeout(200, function() {             $('.thumbnail').fadein(200);         });     }); }); 

with html:

<div class="thumbnail">     <img src="image.jpg" /> </div> <div class="description">     <p>content here</p> </div> 

it works i'd thumbnail fade black background thumbnail image still shows slightly. right now, background shows white when hover on it. how can go doing this? also, there better way write code, perhaps using other mouseenter? i'm still beginner jquery it's new me.

something ideal: http://www.brandingdirection.co.uk/

-- edited tidy ---

final code demo at

text link version: http://jsfiddle.net/thewebdes/lds6c/

image link version: http://jsfiddle.net/thewebdes/jy2e2/1/

html

<div class="thumbnail">     <img src="http://chuvachienes.com/wp-content/uploads/2009/07/hello.jpg" width="200"/>      <div class="description">         <p>content here content here content here content here content here content here content here content here content here content here content here content here content here content here content here content here content here content here content here content here</p>     </div> </div> 

css

.thumbnail { background: #000; width: 200px; height: 200px; overflow: hidden; } .description { display: none; position: relative; top: -190px; left: 10px; color: #fff; font-weight: bold; } 

js

$('.thumbnail').hover(function() {     $('.thumbnail img').stop(true,true).fadeto(400, 0.2);     $('.description').stop(true,true).fadein(400); }, function() {     $('.thumbnail img').stop(true,true).fadeto(400, 1);     $('.description').stop(true,true).fadeout(400); }); 

to make links, either link pieces of text want link or if want whole block link, link image. if linking whole block, avoid confusion should add cursor: pointer .description p otherwise you'll text select cursor instead while you're hovering on text.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -