首先加一個(gè)提示層并隱藏

成都創(chuàng)新互聯(lián)公司是一家以成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、品牌設(shè)計(jì)、軟件運(yùn)維、成都網(wǎng)站營(yíng)銷、小程序App開發(fā)等移動(dòng)開發(fā)為一體互聯(lián)網(wǎng)公司。已累計(jì)為成都門簾等眾行業(yè)中小客戶提供優(yōu)質(zhì)的互聯(lián)網(wǎng)建站和軟件開發(fā)服務(wù)。
div id="addBox" style="display:none;"保存成功/div
點(diǎn)擊添加后顯示,過一段時(shí)間后隱藏
$("$addBox").show();
setTimeout($("$addBox").hide(),3000)
html代碼如下:
input
type="button"
value="顯示"
id="b1"/
jquery代碼如下:
添加jquery引用。。。
script
type="text/javascript"
$(function(){
$("b1").click("彈出一個(gè)窗口頁面")
});
/script
不知樓主說的窗口頁面是否是這樣的。
可以用jDialog插件實(shí)現(xiàn),jDialog是一款基于jquery實(shí)現(xiàn)的輕量級(jí)多種類型的自定義對(duì)話框插件在項(xiàng)目開發(fā)中、一般會(huì)美化 alert();
參考如下:
center
button id="test1"alert方式調(diào)用/button
br/br/
button id="test2"confirm方式調(diào)用/button
br/br/
button id="test3"iframe方式調(diào)用/button
br/br/
button id="test4"只顯示內(nèi)容對(duì)話框/button
br/br/
button id="test5"對(duì)話框配置按鈕/button
br/br/
button id="test6"message方式調(diào)用/button
br/br/
button id="test7"tip方式調(diào)用/button
/center
以下是JS代碼
$("#test1").click(function(){
var dialog = jDialog.alert(′歡迎使用jDialog組件′,{},{
showShadow: false,// 不顯示對(duì)話框陰影
buttonAlign : ′center′,
events : {
show : function(evt){
var dlg = evt.data.dialog;
},
close : function(evt){
var dlg = evt.data.dialog;
},
enterKey : function(evt){
alert(′enter key pressed!′);
},
escKey : function(evt){
alert(′esc key pressed!′);
evt.data.dialog.close();
}
}
});
}) ;
$("#test2").click(function(){
var dialog = jDialog.confirm(′歡迎使用jDialog組件,我是confirm!′,{
handler : function(button,dialog) {
alert(′你點(diǎn)擊了確定!′);
dialog.close();
}
},{
handler : function(button,dialog) {
alert(′你點(diǎn)擊了取消!′);
dialog.close();
}
});
});
$("#test3").click(function(){
// 通過options參數(shù),控制iframe對(duì)話框
var dialog = jDialog.iframe(;,{
title : ′
width : 1100,
height : 550
});
});
$("#test4").click(function(){
// 通過options參數(shù),控制dialog
var dialog = jDialog.dialog({
title : ′自定義對(duì)話框′,
content : ′
});
});
$("#test5").click(function(){
// 通過options參數(shù),控制dialog
var dialog = jDialog.dialog({
title : ′自定義對(duì)話框′,
content : ′;,
buttons : [
{
type : ′highlight′,
text : ′你好′,
handler:function(button,dialog)
{
dialog.close();
}
}
]
});
});
$("#test6").click(function(){
var dialog = jDialog.message(′′,{
autoClose : 3000, // 3s后自動(dòng)關(guān)閉
padding : ′30px′, // 設(shè)置內(nèi)部padding
modal: true // 非模態(tài),即不顯示遮罩層
});
});
$("#test7").click(function(){
var dialog = jDialog.tip(′′,{
target : $(′#test7′),
position : ′left-top′,
trianglePosFromStart :0,
autoClose : 1000,
offset : {
top :-20,
left:10,
right:0,
bottom:0
}
});
})
1、新建并保存一個(gè)html文檔,進(jìn)入html代碼編輯頁面。
2、寫一個(gè)input文本輸入框,并定義ID,然后寫一個(gè)按鈕,并定義ID。
3、要做的效果就是點(diǎn)擊按鈕為輸入框賦值,然后把輸入框和按鈕的css樣式寫好,不寫樣式也可以。
4、引入jquery文件,路徑要正確,寫jquery代碼,打開瀏覽器測(cè)試一下,點(diǎn)擊按鈕之后,輸入框內(nèi)就會(huì)自動(dòng)輸入賦值的內(nèi)容。
html
headtitleSimple jsp page/title
style type="text/css"
!--
#div1 {
position:absolute;
left:338px;
top:91px;
width:446px;
height:294px;
z-index:1;
border:solid #7A7A7A 4px;
}
/style
script
src=""/script
script type="text/javascript"
$(function(){
$("#div1").hide(); //先讓div隱藏
$("#span1").click(function(){
$("#div1").fadeIn("slow");//淡入淡出效果 顯示div
});
$("#span2").click(function(){
$("#div1").fadeOut("slow");//淡入淡出效果 隱藏div
})
});
/script
/head
body
1個(gè)簡(jiǎn)單彈出div的小例子 頁面不是很美觀 效果達(dá)到了p/p/p/p/p/p/
span style="cursor:pointer" id="span1"點(diǎn)我彈出div/span
div id="div1"
div align="right" style="background-color:#CDCDCD;"span id="span2" style="cursor:pointer"關(guān)閉/span
/div
pp
form
username:input type="text"/p /
age:input type="text"/p /
input type="submit" value="submit"/br /
/form
/div
/body
/html
以上代碼直接復(fù)制粘貼,html文件就可以運(yùn)行,可以做彈出操作。
有很多方法實(shí)現(xiàn)的,比如使用alert這種比較丑的彈框,比如
btn.click(function(){
window.alert('內(nèi)容')
});
或者是自己自定義的彈框,那這樣的話你至少得套三個(gè)div,比如
div-----這個(gè)絕對(duì)定位到整個(gè)頁面,如position:absolute;top:0;left:0;right:0;bottom:0;
div-----這個(gè)在父級(jí)元素上面做絕對(duì)定位,也就是彈框的位置
div/div----彈框內(nèi)容
/div
/div
或者是jQuery UI本身所附帶的對(duì)話框功能,那個(gè)百度就出來了,不過不建議用那個(gè),感覺比較丑,還是自己寫一個(gè)好看
當(dāng)然你也可以試著引入其他的UI框架,比如boot都有對(duì)話框的功能,不過建議自己寫,用jQuery寫也比較簡(jiǎn)單
分享題目:jquery彈,jquery彈出div窗口
URL標(biāo)題:http://chinadenli.net/article31/dseehpd.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)站維護(hù)、定制開發(fā)、定制網(wǎng)站、域名注冊(cè)、虛擬主機(jī)
聲明:本網(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í)需注明來源: 創(chuàng)新互聯(lián)