I assume ".jpg" is a real image:
$(function() { // $(function(){}) is a shortcut of $(document).ready(function(){})
var $activeImg; // Maintain a reference to the last activated img
$(".individualImagebox img").click(function(){
if (!!$activeImg) {
$activeImg.attr("src", "function(i, src){
return src.replace(/(.+)Red\.jpg$/, "1ドル.jpg"); // Just replace the src with ".jpg" });
}
$activeImg = $(this).attr("src", "Red.jpg"function(i, src);{ // Replacereplace theattribute srcand withupdates "Redactive img reference
return src.jpg"replace(/(.+)\.jpg$/, and"1ドルRed.jpg");
update $activeImg reference });
});
});
I don’t know exactly what you are trying to do but if possible, you should toggling a class instead of modifying the src attribute.
I assume ".jpg" is a real image:
$(function() { // $(function(){}) is a shortcut of $(document).ready(function(){})
var $activeImg; // Maintain a reference to the last activated img
$(".individualImagebox img").click(function(){
if (!!$activeImg) {
$activeImg.attr("src", ".jpg"); // Just replace the src with ".jpg"
}
$activeImg = $(this).attr("src", "Red.jpg"); // Replace the src with "Red.jpg", and update $activeImg reference
});
});
I don’t know exactly what you are trying to do but if possible, you should toggling a class instead of modifying the src attribute.
$(function() { // $(function(){}) is a shortcut of $(document).ready(function(){})
var $activeImg; // Maintain a reference to the last activated img
$(".individualImagebox img").click(function(){
if (!!$activeImg) {
$activeImg.attr("src", function(i, src){
return src.replace(/(.+)Red\.jpg$/, "1ドル.jpg"); });
}
$activeImg = $(this).attr("src", function(i, src){ // replace attribute and updates active img reference
return src.replace(/(.+)\.jpg$/, "1ドルRed.jpg");
});
});
});
I don’t know exactly what you are trying to do but if possible, you should toggling a class instead of modifying the src attribute.
I assume ".jpg" is a real image:
$(function() { // $(function(){}) is a shortcut of $(document).ready(function(){})
var $activeImg; // Maintain a reference to the last activated img
$(".individualImagebox img").click(function(){
if (!!$activeImg) {
$activeImg.attr("src", ".jpg"); // Just replace the src with ".jpg"
}
$activeImg = $(this).attr("src", "Red.jpg"); // Replace the src with "Red.jpg", and update $activeImg reference
});
});
I don’t know exactly what you are trying to do but if possible, you should toggling a class instead of modifying the src attribute.