I have two divs
, on hover span class=fg
grows and changes opacity, span class=bg
shrinks, and when you mouseout
it returns to the original state.
My problem is in two parts:
1: When hovering over the first div, the same action happens in the second.
2: The hover isn't constrained to the divs, but happens whenever the mouse moves on the page.
HTML:
<div id="wrap">
<h2>Subtitle</h2>
<p>
<span class="bg">Lorem Ipsum has been the</span>
<a href="#"><span class="fg"> industry’s standard</span></a>
<span class="bg">dummy text ever</span>
<span class="fg">since the 1500s,</span>
span class="bg">when an unknown printer took a galley of type and</span>
</p>
</div>
<div id="wrap" class="">
<h2>Stuff #2</h2>
<p>
<span class="bg">Lorem Ipsum has been the</span>
<span class="fg"> industry’s standard</span>
<span class="bg">dummy text ever</span>
<span class="fg">since the 1500s,</span>
<span class="bg">when an unknown printer took a galley of type</span>
</p>
</div>
javaScript:
<script type="text/javascript">
$(document).ready(function() {
$("#wrap").parent().hover (function () {
$("span.fg").animate({"opacity": 1, fontSize: '14px'}, 300);
$("span.bg").animate({fontSize: '7px'}, 300);
},
function () {
$("span.fg").animate({"opacity": .5, fontSize: '12px'}, 100);
$("span.bg").animate({fontSize: '12px'}, 100);}
);
});
CSS:
body {background: #000;color: #FFF;font-family: Helvetica, sans-serif;}
p {font-size:12px;}
#wrap { width: 300px;
height: 150px;
cursor: pointer;
margin: 30px auto;
overflow:hidden;
}
a {text-decoration:none; color:inherit;}
.bg {color:#999; opacity: 0.4;}
.fg {color:#999; opacity: 0.4;}