Hello,
I am aware that this maybe is not a jquery specific problem, yet, my code integrates jquey so I might as well ask it here.
I have the following code:
<script src="edge_includes/jquery-1.7.1.min.js"></script>
<script src="edge_includes/jquery.easing.1.3.js"></script>
<script type="text/javascript" language="JavaScript">
$(document).ready(function(){
$("#sub")
.click(function(){
$("#the_pic").attr('src','images/Memoir_reg/Memoir_1.gif');
$("#the_pic_2").attr('src','images/Memoir_reg/Memoir_2.gif');
$("#the_pic_3").attr('src','images/Memoir_reg/Memoir_3.gif');
$("#the_pic_4").attr('src','images/Memoir_reg/Memoir_4.gif');
$("#the_pic_5").attr('src','images/Memoir_reg/Memoir_5.gif');
$('#sub img').attr('src','images/ita.gif');
});
});
</script>
</head>
<body>
<div class="letters">
<div id="1"><img id="the_pic" class="center fit" src="images/Memoir_ita/Memoir_1.gif"></div>
<div id="2"><img id="the_pic_2" class="center fit" src="images/Memoir_ita/Memoir_2.gif"></div>
<div id="3"><img id="the_pic_3" class="center fit" src="images/Memoir_ita/Memoir_3.gif"></div>
<div id="4"><img id="the_pic_4" class="center fit" src="images/Memoir_ita/Memoir_4.gif"></div>
<div id="5"><img id="the_pic_5" class="center fit" src="images/Memoir_ita/Memoir_5.gif"></div>
</div>
Basically I put 2 sub folders in my "images" folder named "reg" and "ita". In there are pictures which I wanted to change their resource in the divs by introducing a variable so that the paths would look like:
<div id="1"><img id="the_pic" class="center fit" src="images/Memoir_"+style+"/Memoir_1.gif"></div>
and then I wanted to change this variable "style“ to tell him which sub folder to use instead of doing all this:
$("#the_pic").attr('src','images/Memoir_reg/Memoir_1.gif');
$("#the_pic_2").attr('src','images/Memoir_reg/Memoir_2.gif');
$("#the_pic_3").attr('src','images/Memoir_reg/Memoir_3.gif');
$("#the_pic_4").attr('src','images/Memoir_reg/Memoir_4.gif');
$("#the_pic_5").attr('src','images/Memoir_reg/Memoir_5.gif');
and then back.
I think the fault is in the syntax of the path or where to define the variable.
I tried 1000 things but didn’t get this work. :-(
How is this to be done properly.
And (if you like to help me again) how would this be made with toggle,
so that the subfolder changes back and on again on each click?
Thank you so much out there!
Garavani