JQuery顯示隱藏DIV的方法及代碼實(shí)例
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沒有問題
<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>
<!-- 綁定事件似乎要寫在被綁定對(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>
以上代碼之前,可能還要加上這句話:
<script type="text/javascript" src="../../scripts/jquery.min.js"></script>
使用jquery真的很方便,比如要控制div的顯示與隱藏,一句話就搞定了,請(qǐng)看下面使用說明。
$("#id").show()表示display:block,
$("#id").hide()表示display:none;
$("#id").toggle()切換元素的可見狀態(tài)。如果元素是可見的,切換為隱藏的;如果元素是隱藏的,切換為可見的。
$("#id").css('display','none');
$("#id").css('display','block');
或
$("#id")[0].style.display = 'none';
- 基于JQuery的浮動(dòng)DIV顯示提示信息并自動(dòng)隱藏
- jquery顯示和隱藏div特效實(shí)例
- jquery之超簡(jiǎn)單的div顯示和隱藏特效demo(分享)
- 基于jquery實(shí)現(xiàn)的定時(shí)顯示與隱藏div廣告的實(shí)現(xiàn)代碼
- jquery和js實(shí)現(xiàn)對(duì)div的隱藏和顯示方法
- JQuery顯示、隱藏div的幾種方法簡(jiǎn)明總結(jié)
- jQuery基于toggle實(shí)現(xiàn)click觸發(fā)DIV的顯示與隱藏問題分析
- JQuery DIV 動(dòng)態(tài)隱藏和顯示的方法
相關(guān)文章
jQuery刪除當(dāng)前節(jié)點(diǎn)元素
本文給大家分享一段代碼給大家介紹jquery刪除當(dāng)前節(jié)點(diǎn)元素的方法,代碼簡(jiǎn)單易懂,非常不錯(cuò),需要的朋友參考下吧2016-12-12jQuery ajax的功能實(shí)現(xiàn)方法詳解
jQuery的ajax方法非常好用,這么好的東西,你想擁有一個(gè)屬于自己的ajax么?接下來,我們來自己做一個(gè)簡(jiǎn)單的ajax吧2017-01-01AJAX實(shí)現(xiàn)瀑布流觸發(fā)分頁與分頁觸發(fā)瀑布流的方法
瀑布流觸發(fā)分頁可以理解為微博中的瀏覽效果、到一定程度時(shí)顯示頁數(shù)進(jìn)行分頁,而分頁觸發(fā)瀑布流可以理解為Twitter拉到一頁設(shè)定的最大條數(shù)后繼續(xù)用瀑布流展示下一頁,接下來我們就來詳細(xì)看看AJAX實(shí)現(xiàn)瀑布流觸發(fā)分頁與分頁觸發(fā)瀑布流的方法2016-05-05JQuery實(shí)現(xiàn)動(dòng)態(tài)表格點(diǎn)擊按鈕表格增加一行
動(dòng)態(tài)表格,功能為點(diǎn)擊添加按鈕,表格增加一行并給其name屬性賦予的值,點(diǎn)擊刪除,自動(dòng)刪除這一行,具體實(shí)現(xiàn)如下2014-08-08jQuery實(shí)現(xiàn)獲取當(dāng)前鼠標(biāo)位置并輸出功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)獲取當(dāng)前鼠標(biāo)位置并輸出功能,涉及jQuery事件響應(yīng)及頁面元素屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-01-01jquery顯示loading圖片直到網(wǎng)頁加載完成的方法
這篇文章主要介紹了jquery顯示loading圖片直到網(wǎng)頁加載完成的方法,涉及jquery頁面加載與動(dòng)畫效果的使用技巧,需要的朋友可以參考下2015-06-06