JS實(shí)現(xiàn)仿新浪微博發(fā)布內(nèi)容為空時(shí)提示功能代碼
本文實(shí)例講述了JS實(shí)現(xiàn)仿新浪微博發(fā)布內(nèi)容為空時(shí)提示功能。分享給大家供大家參考。具體如下:
這里使用JavaScript模擬新浪微博的一個(gè)功能,在發(fā)布微博的內(nèi)容為空時(shí),文本框提醒用戶這里沒有輸入內(nèi)容,本功能讓人感覺網(wǎng)頁很智能,在和你對(duì)話一樣,很人性化。本特效引用了一個(gè)外部了JS封裝類,你可下載到本地使用。
運(yùn)行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-fsina-info-submit-empty-style-codes/
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>新浪微博發(fā)布功能</title> <style type="text/css"> html,body{margin:0px;text-align:center;font-size:12px;background:#b2e2f9;} .box{width:555px;height:auto;margin:30px auto;background:#fafafa;padding:30px;overflow:hidden;} .boxf{width:555px;height:88px;float:left;position:relative;z-index:0;} #textDisplay{width:555px;height:88px;position:absolute;left:0px;top:0px;word-wrap:break-word;word-break:normal;z-index:1;text-align:left;line-height:20px;font-family:Arial;font-size:12px;} #list{width:164px;position:absolute;padding:1px;border:1px solid #cccccc;display:none;z-index:100;background:#fff;font-family:Arial;} #list ul{margin:0px;padding:0px;float:left;list-style-type:none;} #list li{width:164px;height:23px;float:left;text-indent:10px;line-height:23px;text-align:left;color:#333333;cursor:pointer;} #list li.hove{background:#e6e6e6;} textarea{width:555px;height:88px;border:1px solid #ccc;border-radius:5px;resize:none;position:absolute;top:0px;left:0px;z-index:2;font-family:Arial;font-size:12px;line-height:20px;overflow:hidden;} textarea.hove{border:1px solid #ffb941;} .title{width:555px;height:21px;text-align:left;padding-bottom:20px;} .title span{float:right;color:#0a8cd2; padding-top:5px;} .title span.color{color:#808080;padding:0px;margin-top:-3px;} .title span em{font-style:normal;font-family:Constantia,Georgia;font-size:22px;font-weight:700;} .btnf{width:555px;height:auto;overflow:hidden;padding-top:10px;} .btn{width:82px;height:30px;background:url(images/201209/fb.jpg) no-repeat;cursor:pointer;float:right;} .btnh{background:url(images/fb1.jpg) no-repeat;} .back{background:#ffd4d4;} .fbcg{width:110px;height:42px;background:url(images/fbcg.jpg) no-repeat;position:absolute;top:50%;left:50%;margin:-21px 0 0 -55px;z-index:10;display:none;} .dis{display:block;} .undis{display:none;} #desc{border: 1px dashed #ccc;color:#333;background:#fff;line-height:2;padding:10px;width:533px;border-radius:5px; margin-top:20px;text-align:left;font-family:Arial;font-size:14px;} </style> <script type="text/javascript" src="js/at.js"></script> <script type="text/javascript"> window.onload = function () { atRelease('', 'text', {box : 'box',list : 'list'}); } </script> </head> <body> <div class="box"> <div class="title"> <span id="num140">前任現(xiàn)任人手一個(gè),李晨泡妞神器石頭心走紅 24小時(shí)熱博</span> <img src="images/title.jpg" /> </div> <div class="boxf" id="box"> <textarea id="text" rows="6" cols="60"></textarea> <div class="fbcg"></div> </div> <div class="btnf"> <span class="btn"></span> </div> <dl id="desc"> <dt>功能說明:</dt> <dd>① 限制輸入140字符,超出字符提示數(shù)字變紅;</dd> <dd>② @符關(guān)聯(lián)好友微博列表;</dd> <dd>③ 鍵盤控制微博列表選中;</dd> <dd>④ 超出字符或空微博發(fā)送閃紅;</dd> <dd>⑤ 發(fā)布成功提示。</dd> <dd class="ta-r"></dd> </dl> </div> <div id="list"> <ul> <li>選擇最近@的人或直接輸入</li> <li class="hove">wh鄉(xiāng)下人</li> <li>幸福文盲作家</li> <li>我是張二蛋</li> <li>JD我行我酷</li> <li>色影無極</li> <li>朱心夢(mèng)</li> <li>wh鄉(xiāng)下人</li> <li>幸福文盲作家</li> <li>我是張二蛋</li> </ul> </div> </body> </html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
相關(guān)文章
js代碼實(shí)現(xiàn)無縫滾動(dòng)(文字和圖片)
js無縫滾動(dòng),圖片無縫滾動(dòng),文字無縫滾動(dòng),基于js代碼如何實(shí)現(xiàn),本篇文章給大家詳解js代碼實(shí)現(xiàn)無縫滾動(dòng)(文字和圖片),需要的朋友可以參考下2015-08-08layui實(shí)現(xiàn)登陸界面驗(yàn)證碼
這篇文章主要為大家詳細(xì)介紹了layui實(shí)現(xiàn)登陸界面驗(yàn)證碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11純前端使用ffmpeg實(shí)現(xiàn)視頻壓縮的具體方法及踩坑
這篇文章主要給大家介紹了關(guān)于純前端使用ffmpeg實(shí)現(xiàn)視頻壓縮的具體方法及踩坑,要在前端使用FFmpeg進(jìn)行視頻壓縮,你可以使用FFmpeg的JavaScript,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-12-12js獲取數(shù)組對(duì)象中的全部key和value值
本文主要介紹了js獲取數(shù)組對(duì)象中的全部key和value值,主要使用JavaScript的?map()?函數(shù)和?values()?迭代器來實(shí)現(xiàn)取出數(shù)組對(duì)象的所有key值和value值,感興趣的可以了解下2024-01-01用javascript實(shí)現(xiàn)的激活輸入框后隱藏初始內(nèi)容
用javascript實(shí)現(xiàn)的激活輸入框后隱藏初始內(nèi)容...2007-06-06javascript html5輕松實(shí)現(xiàn)拖動(dòng)功能
這篇文章主要為大家詳細(xì)介紹了javascript html5輕松實(shí)現(xiàn)拖動(dòng)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03動(dòng)態(tài)生成的IFRAME,設(shè)置SRC時(shí)的問題解決分析
動(dòng)態(tài)生成的IFRAME,設(shè)置SRC時(shí)的,不同位置帶來的影響。 以下所說的是在IE7下運(yùn)行的。IE6下也是同樣。 在這個(gè)blog中,直接點(diǎn)擊運(yùn)行代碼,和把下面代碼保存到為網(wǎng)頁在運(yùn)行(以本地文件或域名訪問),效果不一樣。 先看例子:2008-04-04