/** HTML代碼我加了兩個div。但是,我把所有的div在DIV **/
<center>
<h2>show hide div on click using jquery</h2>
<div style="padding:25px;width: 100px;">
<input id="id_radio1" type="radio" name="name_radio1" value="value_radio1" />Radio1
<br />
<input id="id_radio2" type="radio" name="name_radio1" value="value_radio2" />Radio2
</div>
<div align="center" style="padding:25px;width: 300px;">
<div class="divClass">
<div id="div1">This is First (1st) division</div>
<div id="div2">This is Second (2nd) division</div>
<div id="div3">This is third (3rd) division</div>
<div id="div4">This is fourth (4th) division</div>
</div>
</div>
</center>
/**一些修改jQuery的**/
$(document).ready(function() {
$('.divClass div').hide();
$('#id_radio1').click(function() {
$('.divClass div').hide('fast');
$('#div1').show('fast');
$('#div3').show('fast');
});
$('#id_radio2').click(function() {
$('.divClass div').hide('fast');
$('#div2').show('fast');
$('#div4').show('fast');
});
});
這是偉大的,只是一個問題..我必須改變圖片,當點擊...這裏是它是怎麼看.. http://jsfiddle.net/c872Z/1/當我嘗試你的代碼它不顯示我的圖片..:S –
檢查它http://jsfiddle.net/pranavcbalan/c872Z/2/只做了一些更改 –
很高興幫助你:) –