당신이 사용할 수 있습니다에서 가치를 얻을 도움이 될 것입니다 접근 방식 :
$(function() {
var count = 0;
$('#two').click(function(){
$("#imgtwo").attr('src',"resources/items/icon2blue.png");
});
$('#image2').click(function(){ // do it with other images
if(count < 4) {
count++;
} else {
// reset to original image
count = 0;
$("#imgtwo").attr('src',"resources/items/original_image.png");
}
});
});
id
이 another_image
인 것으로 가정합니다. 내가 그렇게 어떻게,
$(function() {
var img_state = true;
$('#two').click(function(){
if(img_state) {
$("#imgtwo").attr('src',"resources/items/icon2blue.png");
} else {
$("#imgtwo").attr('src',"resources/items/another_image.png");
}
img_state = !img_state;
});
});
안녕하세요 스캇 :
또는, 당신은 아마 다음과 같이 수행 할 수 있습니다 토글 이미지를 갖고 싶어? 죄송 합니다만 jquery에 익숙하지 않으므로 익숙하지 않습니다. 고맙습니다 :) – maccas28
일부 코드가 업데이트되어 추가되었지만 완벽하지는 않을 수 있습니다. –