亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

簡(jiǎn)單了解JavaScript彈窗實(shí)現(xiàn)代碼

瀏覽:121日期:2023-10-30 16:50:35

功能

點(diǎn)擊寫(xiě)點(diǎn)什么彈窗,可以輸入文字。

關(guān)閉彈窗時(shí)自動(dòng)保存,并且將彈窗內(nèi)容轉(zhuǎn)換為段落中的文字。

low沒(méi)有下限

實(shí)現(xiàn)

step1 設(shè)置彈窗容器,包含關(guān)閉按鈕和文本區(qū)域,設(shè)置display為隱藏(none),并設(shè)置在頂層。

step2 設(shè)置彈窗按鈕(這里是點(diǎn)擊段落內(nèi)容呀),并書(shū)寫(xiě)對(duì)應(yīng)的js函數(shù)(將彈窗的display顯示)。

step3 設(shè)置關(guān)閉按鈕的js函數(shù),獲取文本并加入到段落中,關(guān)閉彈窗(還是display?。?/p>

代碼

html代碼

<!DOCTYPE html><html><head><meta charset='UTF-8'><title>彈窗</title><link rel='stylesheet' type='text/css' href='http://m.lshqa.cn/bcjs/style.css' rel='external nofollow' ><link rel='stylesheet' rel='external nofollow' ></head><body><p onclick='writeBlog()'>今天想寫(xiě)點(diǎn)什么?</p><div id='open'><div class='open-content'><span onclick='closeit()'><i class='fa fa-close'></i></span><textarea rows='10' cols='90' placeholder='寫(xiě)下生活' ></textarea> </div></div></body> <script type='text/javascript' src='http://m.lshqa.cn/bcjs/show.js'></script></html>

CSS代碼

/* 彈窗 (background) */.open { display: none; /* 默認(rèn)隱藏 */ position: fixed; /* 固定定位 */ z-index: 1; /* 設(shè)置在頂層 */ left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4); }/* 彈窗內(nèi)容 */.open-content { background-color: #fefefe; margin: 10% auto; padding: 20px; border: 1px solid #888; width: 80%; }.textstyle{padding:20px;margin:10% auto;}/* 關(guān)閉按鈕 */.close { color: #aaa; float: right; font-size: 28px; font-weight: bold;}.close:hover,.close:focus { color: black; text-decoration: none; cursor: pointer;}

JS代碼

function writeBlog(){var open=document.getElementById('open');open.style.display='block';}function closeit(){var text=document.getElementById('textstyle').value;document.getElementById('p1').innerHTML+='<br>'+text;document.getElementById('open').style.display='none';}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 黄色网址亚洲 | 国产午夜毛片v一区二区三区 | 欧美成人在线免费 | 玖玖爱精品 | 国产三级借妻 | 久久影院一区二区三区 | 久草综合视频 | 久草在线| 中文字幕在线观看一区二区 | 一级片成人 | 日韩精品一区二三区中文 | 国语精品视频在线观看不卡 | 亚洲图片视频在线观看 | 成人在线观看网址 | 欧美老头老太做爰xxxx | 国产亚洲精品国产 | 国产精品亚洲成在人线 | 久久久国产99久久国产首页 | 99久久精品免费看国产高清 | 久久视频国产 | 国产成人在线免费视频 | 欧美在线一级片 | 波多野结衣被强在线视频 | 永久精品免费影院在线观看网站 | 国产三级视频网站 | 久久精品视频一区二区三区 | 亚洲天堂视频在线免费观看 | 在线观看精品自拍视频 | 女人精aaaa片一级毛片女女 | 国产精品久久久久久一区二区 | 中国美女黄色一级片 | 国产精品久久久久免费视频 | 毛片在线免费观看网站 | 99福利网 | 日本最色视频 | 亚洲国产精品久久网午夜 | 性欧美巨大的视频 | 农村寡妇偷毛片一级 | 欧美一级毛片欧美毛片视频 | 在线中文字幕视频 | 91精品久久国产青草 |