我對jQuery和JavaScript有點新鮮。我有3個圖像正在使用這些方法打開和關閉。切換像單選按鈕的圖像
如何一次只切換一個,類似於單選按鈕。
<form class="num-players-group" action="">
<input type="hidden" id='testbutton'>
<a href="#" class="players2">
<img src="Assets/Menu/DOR_players_2_off.png" style="display:inline-block" class="player-btn" alt="2 off" />
<img src="Assets/Menu/DOR_players_2_on.png" style="display:none" class="player-btn" alt="2" />
</a>
<a href="#" class="players3">
<img src="Assets/Menu/DOR_players_3_off.png" style="display:inline-block" class="player-btn" alt="3 off" />
<img src="Assets/Menu/DOR_players_3_on.png" style="display:none" class="player-btn" alt="3" />
</a>
<a href="#" class="players4">
<img src="Assets/Menu/DOR_players_4_off.png" style="display:inline-block" class="player-btn" alt="4 off" />
<img src="Assets/Menu/DOR_players_4_on.png" style="display:none" class="player-btn" alt="4" />
</a>
</form>
和我使用jQuery也:
$('.players2').click(function() {
$(this).find('img').toggle();
});
$('.players3').click(function() {
$(this).find('img').toggle();
});
$('.players4').click(function() {
$(this).find('img').toggle();
});
我應該使用沿着
$('.players4').not(this).removeClass('player-btn');
你試過這個嗎? http://stackoverflow.com/questions/17541614/use-thumbnail-image-instead-of-radio-button – 2014-10-06 07:23:18