如何根據點擊按鈕來隱藏和顯示內容?我嘗試做,但它不起作用,我不知道什麼是錯的。你可以幫我嗎?根據點擊按鈕隱藏和顯示div(jquery)
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<div id="list" >
<input id="button" type="button" value="Show Status" onclick="ShowHide()" />
</div>
<div id="content2" style="display:none" >
<img src="http://kobylnica.pl/pic/item,69,1,x.jpg" alt="Tekst alternatywny" />
Miejsce na wyświetlenie filmiku i opisu trasy
</div>
<script type="text/javascript">
function ShowHide(){
if ($("#content2").css('display') == 'none'){
$("#content2").show();
$("#button").val("Hide");
}
else{
$("#content2").hide();
$("#button").val("Show Status");
}
}
</script>
你的代碼的工作:http://jsfiddle.net/ barmar/dTN9h/1/ – Barmar
@Barmar - 讓我爲你的皮條客 - > ** http://jsfiddle.net/dTN9h/3/** – adeneo
也許吧是時候更新你的jQuery了,你正在使用一個三年前的jQuery版本。 – adeneo