$(function(){

專注于為中小企業(yè)提供網(wǎng)站制作、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)松江免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了近千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
//?點(diǎn)擊按鈕,DIV彈出隱藏
$('#btn1').toggle(function(){
$('#div1').show();
},function(){
$('#div1').hide();
});
//?點(diǎn)擊按鈕,DIV彈出,點(diǎn)擊body任意地方隱藏div
$('#btn2').click(function(){
if?(?event??event.stopPropagation?)?{?
//?this?code?is?for?Mozilla?and?Opera?
event.stopPropagation();?
}?
else?if?(window.event)?{?
//?this?code?is?for?IE?
window.event.cancelBubble?=?true;?
}
$('#div2').show();
});
$(document).click(function(){
$('#div2').hide();
});
});
以上都必須要基于,div的css是合理的。
其中?event.stopPropagation(); 和?window.event.cancelBubble = true; 是阻止事件冒泡的寫法,建議自行百度學(xué)習(xí)。
css:(這里用了fixed,不考慮兼容性)
/*?水平垂直居中的div?*/
#div1,#div2{
position:?fixed;
top:?50%;
left:?50%;
background:red;
width:100px;
height:100px;
margin:-50px?0?0?-50px;
display:none;
}
同樣的功能有很多插件,例如fancybox,fancyzoom等
div input id='input1' type='text' /div
div ?id='b' style='position:absolute;left:20px;top:20px;display='none''/div//自己調(diào)整left和top的值將下面的div定位在上一個(gè)div的正下方
引如jquery文件
script
$(function(){
$("#b").hide();
$("#input1").focus(function(){
$("#b").slideDown("slow");
});
$("#input1").blur(function(){
$("#b").slideUp("slow");
});
});
/script
php我不知道怎么做,不知道和jsp是不是一樣的,不會(huì)php
1、在jsp中,你用jquery或者javascript非常好實(shí)現(xiàn),當(dāng)點(diǎn)擊性別時(shí),點(diǎn)擊就是個(gè)事件,這個(gè)事件所要做的事情就是顯示一個(gè)男女的DIV
2、當(dāng)在男女的DIV上選擇了性別后,隱藏這個(gè)div,并且在性別那顯示我們所選擇的性別男或女,我可以可以在隱藏的時(shí)候,把選擇的那個(gè)男或者女賦
值給性別DIV中的性別那一欄
3、學(xué)習(xí)下jqeury或者javascript實(shí)現(xiàn)起來(lái)超容易
4、下面是我寫的js代碼,你看你php能否同樣做出來(lái),按照這個(gè)方法
!DOCTYPE
html
head
!-- 聲明當(dāng)前頁(yè)面的編碼集charset=gbk中文編碼gb2312,charset=utf-8國(guó)際編碼 --
meta http-equiv="Content-Type" content="text/html; charset=utf-8"
!-- 當(dāng)前頁(yè)面三要素 --
titletitle/title
meta name="Author" content="cn.huanghaiping"
meta name="Keywords" content="關(guān)鍵詞,關(guān)鍵詞"
meta name="Description" content="描述"
!-- css , js --
/head
body
divinput type="text" id="sextxt"input type="button" value="性別" id="sex" onclick="showsex()"/div
div id="sexradio" style="margin-top:10px;display:none;"
input type="radio" name="sex" value="男" onclick="selectsex(this)" 男
input type="radio" name="sex" value="女" onclick="selectsex(this)" 女
/div
script
function showsex(){
document.getElementById("sexradio").style.display = "block";
}
function selectsex(o){
document.getElementById("sextxt").value = o.value
document.getElementById("sexradio").style.display = "none";
}
/script
/body
/html
style
.box{width:400px;height:400px;background:#f00;position:fixed;top:?50%;left:?50%;}
/style
var?html?=?'div?class="box"/div';
$('body').append(html);
var?L?=?$('.box').width();
var?T?=?$('.box').height();
$('.box').css({
"margin-left":-L/2,
"margin-top":-T/2
})
當(dāng)前文章:jquery彈出div,jquery彈出框
文章地址:http://chinadenli.net/article32/dsehepc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、服務(wù)器托管、網(wǎng)站制作、網(wǎng)站排名、Google、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)