Ive have read like 100+ your topics on this, but no matter what i do i cant get it do like i want to. My problem is i get my img src="url" from my script. When i alert it it gives me the right input i want, but when i put it in the attr() tag i just posts "imgSrc" and that in the path to the image. When i hard code the images in the mouseover function it actully works.
Heres my Script
<script>
$(document).ready(function(){
//Hides the images
$('#imgwrap img').hide();
//Create variables for Link & Images
$('a.imgflash').mouseover(function(){
var linkRel = $(this).attr('rel');
$('#imgwrap img').each(function(i,ele){
if($(this).attr('rel') == linkRel) {
var imgSrc = $(this).attr('src');
}
});
});
//Script that makes images apears
//Mouseover Script
$('a.imgflash').mouseover(function(){
$('#imgwrap img').attr("src", imgSrc).show();
});
});
</script>
And heres my HTML
<ul>
<li><a rel="demo1" class="imgflash" href="#">demo1</a></li>
<li><a rel="demo2" class="imgflash" href="#">demo2</a></li>
<li><a rel="demo3" class="imgflash" href="#">demo3</a></li>
</ul>
<div id="imgwrap" style="width:300px; height:300px; overflow:hidden;">
<img rel="demo1" src="images/lux.jpg">
<img rel="demo2" src="images/cover.jpg">
<img rel="demo3" src="images/cover2.jpg">
</div>
i hope u can help me how to get my Variable "imgSrc" to post like i want to in my mouseover function.
$('a.imgflash')- the local variables (eg imgSrc) created in one are not available in the other. Why two? From the code I can't even tell what you are trying to do. Can you explain what you want to happen on mouse over?