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沒有問題
<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';
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)文章
jquery1.4 教程一 便利的設(shè)置函數(shù)
jquery1.4已經(jīng)發(fā)布了,1.4相對(duì)于1.32的改進(jìn)還是非常巨大的,可以說是全面性的,性能也全面超越了1.32。這一周,將一一展示jquery1.4的改進(jìn),同時(shí)也會(huì)放出相應(yīng)的demo。2010-02-02
jQuery將多條數(shù)據(jù)插入模態(tài)框的示例代碼
這篇文章主要介紹了使用jQuery將多條數(shù)據(jù)插入模態(tài)框的方法,很簡(jiǎn)單,很實(shí)用,需要的朋友可以參考下2014-09-09
利用jqgrid實(shí)現(xiàn)上移下移單元格功能
這篇文章主要給大家介紹了關(guān)于如何利用jqgrid實(shí)現(xiàn)上移下移單元格功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-11-11
jquery移動(dòng)節(jié)點(diǎn)實(shí)例
這篇文章主要介紹了jquery移動(dòng)節(jié)點(diǎn)的實(shí)現(xiàn)方法,主要涉及append()方法的使用技巧,需要的朋友可以參考下2015-01-01
來自國(guó)外的30個(gè)基于jquery的Web下拉菜單
來自國(guó)外的30個(gè)基于jquery的Web下拉菜單,需要的朋友可以參考學(xué)習(xí)下2012-06-06
jQuery實(shí)現(xiàn)王者榮耀手風(fēng)琴效果
這篇文章主要介紹了jQuery實(shí)現(xiàn)王者榮耀手風(fēng)琴效果的代碼內(nèi)容,需要的朋友們可以學(xué)習(xí)下。2020-01-01
使用Jquery來實(shí)現(xiàn)可以輸入值的下拉選單 雛型
最近案子中,需要使用下拉選單,但問題是,里面選項(xiàng)都會(huì)有各 其他:,然後 可以 讓 user 在輸入2011-12-12
JQuery實(shí)現(xiàn)左右滾動(dòng)菜單特效
這篇文章主要介紹了jquery實(shí)現(xiàn)左右滑動(dòng)菜單效果代碼,涉及jquery鼠標(biāo)事件相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09

