2
我想用所有匹配類中的圖像src替換2的1。我已經嘗試了類似的特定元素,那是行得通的,但我無法讓它適用於所有匹配的類。如何更改第一個電話的格式,以便它可以工作?謝謝。JQuery替換src屬性子字符串
$(".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
}
}
);