$(document).ready(function() {
$("#MenuBar1 li").mouseover(function() {
$("#back").attr("src", $(this).data("img"));
$('.description').text($(this).data('description'));
}).mouseout(function() {
$("#back").attr("src", $("#back").data("original"));
});
});
HTML code:
<div>
<div style="width: 377px; position:relative; left: 395px;">
<ul id="MenuBar1" class="MenuBarHorizontal">
<div style="height:20px;">
<li id="button1" data-img="http://http://demo/images/anne.jpg" width="357" height="241" border="0">
<a href="#">Anywhere</a>
</li>
</div>
<div style="height:20px;">
<li id="button2" data-img="http://demo/images/Banner.jpg">
<a href="#">ware</a>
</li>
</div>
<div style="height:20px;">
<li id="button3" data-img="http://demo/images/Banner.jpg">
<a href="#">Demand</a>
</li>
</div>
<div style="height:20px;">
<li id="button4" data-img="http:http://demo/images/Bans.jpg">
<a href="#">CM</a>
</li>
</div>
<div style="height:20px;">
<li id="button5" data-img="http://demo/images/eat.jpg">
<a href="#">Key</a>
</li>
</div>
</a></li></div>
</ul>
</div>
<div style="width: 357px; position: relative; top: -380px;" id="content">
<img id="back"src="http://demo/images/Banner.jpg"data-original="http://demo/images/Banner.jpg" alt="e.s.t" />
</div>
<div>
<p>put text content here for each hover</p>
</div>
Looks like malformed HTML in the image tag
Missing space between between id , data attributes…
EDIT
Check FIDDLE
I have added the description class to the div.
Also added the data-description attribute to the li tags..
Check the example above..
UPDATED
You are trying to access the defaultText variable which has scope only in the first function. Try declaring it outside of the mouseover event .. You just now encountered a scoping bug 😀 ;