一致するすべてのクラスの画像srcの2を1に置き換えたいと思います。特定の要素に対して同様のことを試しましたが、それは機能しますが、一致するすべてのクラスで機能させることはできません。最初の呼び出しの形式を変更して機能させるにはどうすればよいですか?ありがとう。
$(".in1, .in2, .in3").click(
function()
{
$(".in1, .in2, .in3").attr("src").replace("2","1");// This doesn't work
if(this.src.indexOf("1")!=-1){
this.src = this.src.replace("1","2"); // This works
}else{
this.src = this.src.replace("2","1"); // This works
}
}
);