最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js仿微博動(dòng)態(tài)欄功能

 更新時(shí)間:2017年02月22日 11:04:00   作者:漫步未來  
本文主要介紹了js仿微博動(dòng)態(tài)欄功能的示例代碼,具有很好的參考價(jià)值,下面跟著小編一起來看下吧

知識(shí)有限,目前只寫了發(fā)布動(dòng)態(tài)的功能,沒有寫兼容,后面再慢慢完善。嘿嘿

效果圖:

代碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>微博</title>
 <style>
  body, p, img, ul, li { margin: 0; padding: 0; }
  body { background-image: url("http://cdn.attach.qdfuns.com/notes/pics/201612/07/212742f92tpe2wve095ttp.jpg");}
  li { list-style: none; }
  .box {
   padding-top: 20px;
   margin: 20px auto;
   width: 620px;
   height: 180px;
   position: relative;
   background-color: #ffffff;
   text-align: center;
  }
  .box label {
   font: 18px/18px "微軟雅黑";
   color: #cccccc;
   position: absolute;
   top: 60px;
   left: 40px;
   cursor: text;
  }
  .H {
   float: left;
   padding: 5px 0 5px 10px;
   color: #426B80;
   font: 400 16px/16px "宋體";
  }
  textarea {
   padding: 5px;
   border-color: #CCCCCC;
   width: 580px;
   height: 80px;
   resize: none;
   outline:none;
   font: 400 18px "微軟雅黑";
   color: #333333;
  }
  #button {
   width: 80px;
   height: 34px;
   display: block;
   background-color: #FFC09F;
   position: absolute;
   top: 148px;
   right: 14px;
   text-align: center;
   line-height: 34px;
   color: #ffffff;
   cursor: pointer;
   /*F7671D*/
  }
  .dynamic {
   text-align: left;
   padding: 10px 10px;
   width: 580px;
   height: 100%;
  }
  .user {
   position: relative;
  }
  .user img {
   border: solid 1px #CCCCCC;
   vertical-align: top;
  }
  .user .name {
   display: block;
   position: absolute;
   top: 8px;
   left: 60px;
   font: 600 18px/18px "微軟雅黑";
  }
  .time{
   display: block;
   position: absolute;
   top: 55px;
   left: 80px;
   font: 500 10px/10px "微軟雅黑";
  }
  .dynamic .user {
   margin: 10px 5px 0 10px;
  }
  .dynamic .list {
   font: 500 16px/16px "微軟雅黑";
   padding-left: 70px;
  }
 </style>
 <script>
  window.onload = function () {
   //獲取當(dāng)前時(shí)間函數(shù)
   function time() {
    var maydate = new Date();
    var Time = maydate.getFullYear() + "-" + (maydate.getMonth()+1) +"-"+maydate.getDate()+" "+maydate.getHours()+":"+maydate.getMinutes();
    return Time;
   }
   //獲取ID函數(shù)
   function $(id) {return document.getElementById(id);}
   //創(chuàng)建節(jié)點(diǎn)函數(shù)
   function nweChild(id,text) {
    //獲得節(jié)點(diǎn)ID
    var parent = $(id);
    //獲得body所有的孩子
    var child = parent.parentNode.children;
    //克隆當(dāng)前節(jié)點(diǎn)和其所有子節(jié)點(diǎn)
    var newNode = parent.cloneNode(true);
    //給當(dāng)前節(jié)點(diǎn)的父節(jié)點(diǎn)插入克隆的節(jié)點(diǎn)
    parent.parentNode.insertBefore(newNode,child[1]);
    //插入的克隆節(jié)點(diǎn)更換ID
    child[1].id = id + (child.length - 2);
    //改變時(shí)間
    //獲取當(dāng)前id節(jié)點(diǎn)的所有孩子
    var idChild = child[1].children;
    idChild[0].innerHTML = time();
    idChild[2].innerHTML = $("text").value;
   }
   //獲得焦點(diǎn)改變邊框顏色和恢復(fù)默認(rèn)字體顏色
   $("text").onfocus = function () {
    this.style.borderColor = "#FA7D3C";
    this.style.color = "#333333";
   }
   //失去焦點(diǎn)恢復(fù)默然邊框顏色,改變字體顏色
   $("text").onblur = function () {
    this.style.borderColor = "#CCCCCC";
    this.style.color = "#CCCCCC";
   }
   //監(jiān)聽輸入事件
   $("text").oninput = function () {
    if($("text").value != ""){
     //隱藏提示文本
     $("txt").style.display = "none";
     //文本域不為空 按鈕可點(diǎn)擊
     $("button").style.backgroundColor = "#FF8140";
    }else{
     //顯示提示文本
     $("txt").style.display = "block";
     //文本域?yàn)榭?按鈕不可點(diǎn)擊
     $("button").style.backgroundColor = "#FFC09F";
    }
   }
   //按鈕事件
   $("button").onmousemove = function () {
    //當(dāng)文本域不為空?qǐng)?zhí)行下面按鈕事件
    if($("text").value != ""){
     $("button").onmouseout= function () {
      //如果不為空 按鈕為亮色
      if($("text").value != ""){
this.style.backgroundColor = "#FF8140";
      }else {
       //恢復(fù)按鈕為不可點(diǎn)擊顏色
       $("button").style.backgroundColor = "#FFC09F";
      }
     }
     //按鈕為高亮
     this.style.backgroundColor = "#F7671D";
     //調(diào)用節(jié)點(diǎn)函數(shù),并把傳遞當(dāng)前文本內(nèi)容
     $("button").onclick = function () {
      if($("text").value != ""){
       nweChild("order",$("text").value);
      }
      //清空當(dāng)前文本
      $("text").value = "";
      //恢復(fù)按鈕為不可點(diǎn)擊顏色
$("button").style.backgroundColor = "#FFC09F";
      //更改提示文本內(nèi)容
      $("txt").innerHTML = "你看,沒騙你吧!"
      //顯示提示文本
      $("txt").style.display = "block";
     }
    }
   }
  }
 </script>
</head>
<body>
 <div class="box">
  <span class="H">有什么新鮮事想告訴大家?</span>
  <textarea name="text" id="text"></textarea>
  <label for="text" id="txt">輸入一段話,點(diǎn)發(fā)布會(huì)有驚喜哦!</label>
  <span id="button">發(fā)布</span>
 </div>
 <div class="box dynamic" id="order">
  <span class="time">2016-12-07 21:20</span>
  <div class="user">
   <img src="http://cdn.attach.qdfuns.com/notes/pics/201612/07/212742m96ugh87fzxhuuxp.jpg" width=50; alt="頭像">
   <span class="name">漫步未來</span>
  </div>
  <ul class="list">
   <li>未來的你,一定會(huì)感謝現(xiàn)在拼命的自己。</li>
  </ul>
 </div>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

  • js滾動(dòng)條多種樣式,推薦

    js滾動(dòng)條多種樣式,推薦

    [紅色]js滾動(dòng)條多種樣式,推薦...
    2007-02-02
  • 淺談利用JavaScript進(jìn)行的DDoS攻擊原理與防御

    淺談利用JavaScript進(jìn)行的DDoS攻擊原理與防御

    這篇文章主要介紹了淺談利用JavaScript進(jìn)行的DDoS攻擊原理與防御,以及介紹了相關(guān)的中間人攻擊原理,需要的朋友可以參考下
    2015-06-06
  • 微信小程序?qū)崿F(xiàn)鼠標(biāo)拖動(dòng)效果示例

    微信小程序?qū)崿F(xiàn)鼠標(biāo)拖動(dòng)效果示例

    這篇文章主要介紹了微信小程序?qū)崿F(xiàn)鼠標(biāo)拖動(dòng)效果,涉及微信小程序事件綁定及元素屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2017-12-12
  • Bootstrap的圖片輪播示例代碼

    Bootstrap的圖片輪播示例代碼

    Bootstrap 是一個(gè)用于快速開發(fā) Web 應(yīng)用程序和網(wǎng)站的前端框架。Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的。本文給大家分享Bootstrap的圖片輪播示例代碼,小伙伴們快來圍觀吧。
    2015-08-08
  • JavaScript中的數(shù)組特性介紹

    JavaScript中的數(shù)組特性介紹

    這篇文章主要介紹了JavaScript中的數(shù)組特性介紹,本文總結(jié)了數(shù)組的3種特性和4種創(chuàng)建數(shù)組的方法,需要的朋友可以參考下
    2014-12-12
  • kindeditor編輯器點(diǎn)中圖片滾動(dòng)條往上頂?shù)腷ug

    kindeditor編輯器點(diǎn)中圖片滾動(dòng)條往上頂?shù)腷ug

    這篇文章主要介紹了kindeditor編輯器點(diǎn)中圖片滾動(dòng)條往上頂?shù)腷ug的相關(guān)資料,需要的朋友可以參考下
    2015-07-07
  • javascript數(shù)組去重的六種方法匯總

    javascript數(shù)組去重的六種方法匯總

    數(shù)組去重復(fù)是一個(gè)常見的需求,我們暫時(shí)考慮同類型的數(shù)組去重復(fù)。主要是理清思路和考慮下性能。以下方法,有各人總結(jié)也有網(wǎng)上熱心網(wǎng)友的方法,這里簡(jiǎn)單地總結(jié)一下。
    2015-08-08
  • Javascript 原型和繼承(Prototypes and Inheritance)

    Javascript 原型和繼承(Prototypes and Inheritance)

    前面我們看到了如何使用 constructor 來初始化對(duì)象。如果這樣做,那么每一個(gè)創(chuàng)建的新對(duì)象都會(huì)對(duì)那些相同的屬性,方法建立一個(gè)獨(dú)立的副本。而實(shí)際上有更加有效的方法來指定方法,常量,以及其他一些可被所有該類的對(duì)象共享的屬性。
    2009-04-04
  • js print打印網(wǎng)頁指定區(qū)域內(nèi)容的簡(jiǎn)單實(shí)例

    js print打印網(wǎng)頁指定區(qū)域內(nèi)容的簡(jiǎn)單實(shí)例

    下面小編就為大家?guī)硪黄猨s print打印網(wǎng)頁指定區(qū)域內(nèi)容的簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-11-11
  • bootstrap實(shí)現(xiàn)二級(jí)下拉菜單效果

    bootstrap實(shí)現(xiàn)二級(jí)下拉菜單效果

    這篇文章主要為大家詳細(xì)介紹了bootstrap實(shí)現(xiàn)二級(jí)下拉菜單效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11

最新評(píng)論

云南省| 墨脱县| 孝义市| 益阳市| 阿城市| 牡丹江市| 武夷山市| 边坝县| 边坝县| 勐海县| 嘉荫县| 光泽县| 潢川县| 东平县| 永宁县| 若羌县| 玉田县| 远安县| 德清县| 永兴县| 岚皋县| 台安县| 福鼎市| 淮阳县| 佛冈县| 清徐县| 阿拉善右旗| 岳阳县| 吴桥县| 卢湾区| 牙克石市| 罗山县| 茌平县| 宜兰县| 莫力| 盱眙县| 盐城市| 古交市| 江达县| 禹州市| 赤壁市|