I have 2 spans.
First one: <span class="body">
Second one: <span class="desc">
My CSS:
.desc {display: none;}
What I want to do, is show the second span, when hovering the first. No fancy effects or anything, just show the span. I know there is a simple jQuery solution out there, but I'm new to jQuery so I'd appreciate some help finding it. ;)
This is what I have so far. Is the syntax correct?
<script>
$(document).ready(function() {
$(".body").hover(function () {
$(".desc").toggle();
})
})
</script>
UPDATE!
As @thenduks pointed out, this results in every .desc
element to show when a .body
is hovered. As you can probably imagine, I have several .body
and .desc
and I only want the corresponding .desc
to show on hovering the .body
.
This is part of my markup: (the whole site is still just local, so I can't give you an url to test - sorry)
<ul class="form">
<li>
<label class="grid_3 alpha caption" for="from_name">Navn/Firma</label>
<span class="grid_4 body"><input type="text" id="from_name" name="form[from_name]" size="20" value=""></span>
<span class="grid_5 omega validation"><span class="formNoError" id="component74">Udfyld navn eller firma for afhentningsadressen.</span></span>
<span class="grid_5 omega desc" style="display: none;"><p>Navnet på afsenderen.</p></span>
</li>
<li>
<label class="grid_3 alpha caption" for="from_address1">Adresse</label>
<span class="grid_4 body"><input type="text" id="from_address1" name="form[from_address1]" size="20" value=""></span>
<span class="grid_5 omega validation"><span class="formNoError" id="component75">Udfyld afhentningsadressen.</span></span>
<span class="grid_5 omega desc" style="display: none;"><p>Adressen på afsenderen.</p></span>
</li>
<li>
<label class="grid_3 alpha caption" for="from_address2">Adresse 2</label>
<span class="grid_4 body"><input type="text" placeholder="etage/lejlighedsnr./e.l." id="from_address2" name="form[from_address2]" size="20" value=""></span>
<span class="grid_5 omega validation"><span class="formNoError" id="component76">Invalid Input</span></span>
<span class="grid_5 omega desc" style="display: none;"><p></p></span>
</li>
</ul>