JQuery DIV 動(dòng)態(tài)隱藏和顯示的方法
1. 如果在載入是隱藏:
<head> <script language="javascript"> function HideWeekMonth() { $("#tt1").hide(); $("#tt2").hide(); } </script> </head> <body onLoad="HideWeekMonth()"> </body>
2. 動(dòng)態(tài)隱藏和顯示:
<td> <!-- 能用 <input id="btnShow" type="button" value="<?php echo $ini_array['module.insert'];?>" class="btn" /> <input id="btnHide" type="button" value="<?php echo $ini_array['module.insert'];?>" class="btn" /> --> <!-- 直接使用按鈕的id沒(méi)有問(wèn)題 <input id="tt" type="text" name="title" maxlength="50" size="50"></td> --> <input id="btnOne" type="radio" name="frequence" value="1" checked='checked'><?php echo $ini_array['time.one']?> <input id="btnDay" type="radio" name="frequence" value="2"><?php echo $ini_array['time.day']?> <input id="btnWeek" type="radio" name="frequence" value="3"><?php echo $ini_array['time.week']?> <input id="btnMonth" type="radio" name="frequence" value="4"><?php echo $ini_array['time.month']?> <br> <!-- 能用 <div id="tt1"><input type="text" name="title" maxlength="50" size="50" value="tt1"></div> <div id="tt2"><input type="text" name="title" maxlength="50" size="50" value="tt2"></div> --> <div id="tt1"> <br> 1 <input type="checkbox" value="1" name="w1"> 2 <input type="checkbox" value="1" name="w2"> </div> <div id="tt2"> 03 <input type="checkbox" name="m3"> 04 <input type="checkbox" name="m4"> </div> </td> <!-- 綁定事件似乎要寫(xiě)在被綁定對(duì)象的后面 --> <script type="text/javascript" > $("#btnOne").bind("click", function(event) { $("#tt1").hide(); $("#tt2").hide(); }); $("#btnDay").bind("click", function(event) { $("#tt1").hide(); $("#tt2").hide(); }); $("#btnWeek").bind("click", function(event) { $("#tt1").show(); $("#tt2").hide(); }); $("#btnMonth").bind("click", function(event) { $("#tt1").hide(); $("#tt2").show(); }); </script>
以上代碼之前,可能還要加上這句話(huà):
<script type="text/javascript" src="../../scripts/jquery.min.js"></script>
使用jquery真的很方便,比如要控制div的顯示與隱藏,一句話(huà)就搞定了,請(qǐng)看下面使用說(shuō)明。
$("#id").show()表示display:block, $("#id").hide()表示display:none;
$("#id").toggle()切換元素的可見(jiàn)狀態(tài)。如果元素是可見(jiàn)的,切換為隱藏的;如果元素是隱藏的,切換為可見(jiàn)的。
$("#id").css('display','none'); $("#id").css('display','block');
或
$("#id")[0].style.display = 'none';
PS:下面給大家介紹jquery顯示隱藏div標(biāo)簽的幾種方法
1、$("#demo").attr("style","display:none;");//隱藏div
$("#demo").attr("style","display:block;");//顯示div
2、$("#demo").css("display","none");//隱藏div
$("#demo").css("display","block");//顯示div
3、$("#demo").hide();//隱藏div
$("#demo").show();//顯示div
4、$("#demo").toggle(
function () { $(this).attr("style","display:none;");//隱藏div }, function () { $(this).attr("style","display:block;");//顯示div } ); <div id="demo"></div>
相關(guān)文章
jQuery實(shí)現(xiàn)的解析本地 XML 文檔操作示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的解析本地 XML 文檔操作,結(jié)合實(shí)例形式分析了jQuery針對(duì)本地 XML 文檔的解析及ajax交互相關(guān)操作技巧,需要的朋友可以參考下2020-04-04Jquery和JS獲取ul中l(wèi)i標(biāo)簽的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇Jquery和JS獲取ul中l(wèi)i標(biāo)簽的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06jQuery實(shí)現(xiàn)可移動(dòng)選項(xiàng)的左右下拉列表示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)可移動(dòng)選項(xiàng)的左右下拉列表,涉及jQuery針對(duì)表格table及頁(yè)面元素動(dòng)態(tài)操作的相關(guān)技巧,需要的朋友可以參考下2016-12-12jQuery 出現(xiàn)Cannot read property ‘msie’ of undefined錯(cuò)誤的解決方法
這篇文章主要介紹了jQuery 出現(xiàn)Cannot read property ‘msie’ of undefined錯(cuò)誤的解決方法的相關(guān)資料,需要的朋友可以參考下2016-11-11JQuery一種取同級(jí)值的方式(比如你在GridView中)
JQuery一種取同級(jí)值的方式 比如你在GridView中,實(shí)現(xiàn)代碼如下,需要的朋友可以參考下2012-03-03javascript權(quán)威指南 學(xué)習(xí)筆記之null和undefined
JavaScript中的關(guān)鍵字null是一個(gè)特殊的值,它表示“無(wú)值”。null常常被看作對(duì)象類(lèi)型的一個(gè)特殊值,即代表“無(wú)對(duì)象”的值。2011-09-09