function updateOption(selection, option) {
jQuery('body,html').animate({
scrollTop: jQuery("#msg").offset().top
}, 800);
jQuery('.'+selection).each(function() {
jQuery("img."+selection).removeClass("optionSelected");
});
jQuery.ajax({
type: "GET",
url: "../v1_include/v1_session_boutique.inc.php",
data: selection + "=" + option,
success: function(msg){
jQuery('#msg').fadeIn('fast');
var List = document.getElementById('msg');
List.innerHTML = msg;
jQuery(".StoreMsgPanier").animate( { opacity: 0.25 }, 1000)
.animate( { opacity: 1 }, 1000);
}
});
}
<p>Option 1</p>
<div id="opt3">
<a href="javascript:updateOption('select_1_3','1-5-1');"><img src="../v1_images_option/crop/5_1.jpg" alt="" style="margin:2px;padding:5px;border:1px solid #D6D6D6" class="select_1_3 optionSelected" /></a>
<a href="javascript:updateOption('select_1_3','1-6-1');"><img src="../v1_images_option/crop/6_1.jpg" alt="" style="margin:2px;padding:5px;border:1px solid #D6D6D6" class="select_1_3" /></a>
</div>
<p>Option 2</p>
<div id="opt2">
<a href="javascript:updateOption('select_1_2','1-3-1');"><img src="../v1_images_option/crop/3_1.jpg" alt="" style="margin:2px;padding:5px;border:1px solid #D6D6D6" class="select_1_2" /></a>
<a href="javascript:updateOption('select_1_2','1-4-1');"><img src="../v1_images_option/crop/4_1.jpg" alt="" style="margin:2px;padding:5px;border:1px solid #D6D6D6" class="select_1_2" /></a>
</div>
このコードは正常に機能しますが、すべての'optionSelected'クラスを削除した後、クリックしたばかりの画像にのみ'optionSelected'を追加するにはどうすればよいですか?
ご協力いただきありがとうございます...