JavaScript實(shí)現(xiàn)簡單評(píng)論功能
更新時(shí)間:2017年08月17日 08:37:37 作者:wwj18368915379
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)簡單評(píng)論功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了JavaScript實(shí)現(xiàn)簡單評(píng)論功能的具體代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> body{ /*background-image: url(../img/91R58PIC3n2_1024.jpg);*/ } #div1{ margin: auto; border: 1px beige solid; width: 512px; text-align: right; } ul{ list-style-type: none; list-style-image: url(../img/touxiang.png); } .box{ width: 400px; height: 150px; /*background-color: yellow;*/ border: 1px darkgray solid; border-radius: 30px; position: relative; } .box .touxiang{ width: 80px; height: 80px; background-image: url(../img/touxiang.png); background-size: 100% 100%; position: absolute; left: 10px; top: 10px; } .box .nicheng{ width: 80px; height:25px ; /*background-color: red;*/ position: absolute; left: 10px; top: 100px; font-size: 12px; text-align: center; line-height: 25px; } .box .pinglun{ width: 290px; height: 80px; /*background-color: cyan;*/ position: absolute; top: 10px; right: 10px; } .box .shijian{ width: 200px; height: 25px; /*background-color: green;*/ position: absolute; top: 100px; left:100px; } </style> <script> window.onload=function(){ var oTxt = document.getElementById("txt"); var oBtn = document.getElementById("btn1"); var oUl1 = document.getElementById("ul1"); oBtn.onclick=function(){ var oBox = document.createElement("div"); oBox.className = "box"; //創(chuàng)建頭像 var oDiv = document.createElement("div"); oDiv.className = "touxiang"; oBox.appendChild(oDiv); var oDiv = document.createElement("div"); oDiv.className = "nicheng"; oDiv.innerHTML = "指尖微涼*"; oBox.appendChild(oDiv); var oDiv = document.createElement("div"); oDiv.className = "pinglun"; oDiv.innerHTML = oTxt.value; oBox.appendChild(oDiv); var oDiv = document.createElement("div"); oDiv.className = "shijian"; var oDate = new Date(); //oDate.getFullYear oDiv.innerHTML ="評(píng)論時(shí)間 "+ oDate.getFullYear()+"年"+(oDate.getMonth()+1)+"月"+oDate.getDate()+"日"+"<a href='javascript:;'>刪除</a>"; oBox.appendChild(oDiv); oUl1.appendChild(oBox); /*oBox.insertBefore(oUl1,oDiv[0]);*/ var aA = oDiv.getElementsByTagName("a"); for(var i = 0;i<aA.length;i++) { aA[i].onclick=function(){ oDiv.removeChild(this.parentNode); } } } } </script> </script> </head> <body> <h2 align="center">網(wǎng)易云熱評(píng)</h2> <div id="div1" > <textarea cols="70" rows="8" id="txt"></textarea><br /> <input type="button" value="評(píng)論" id="btn1" /> <ul id="ul1"> </ul> </div> </body> </html>
效果圖:
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 原生js實(shí)現(xiàn)回復(fù)評(píng)論功能
- JavaScript評(píng)論點(diǎn)贊功能的實(shí)現(xiàn)方法
- vue.js評(píng)論發(fā)布信息可插入QQ表情功能
- Vue.js實(shí)現(xiàn)文章評(píng)論和回復(fù)評(píng)論功能
- JS類定義原型方法的兩種實(shí)現(xiàn)的區(qū)別評(píng)論很多
- vue.js實(shí)現(xiàn)用戶評(píng)論、登錄、注冊(cè)、及修改信息功能
- 使用AngularJS和PHP的Laravel實(shí)現(xiàn)單頁評(píng)論的方法
- js寫的評(píng)論分頁(還不錯(cuò))
- react結(jié)合bootstrap實(shí)現(xiàn)評(píng)論功能
相關(guān)文章
Bootstrap實(shí)現(xiàn)input控件失去焦點(diǎn)時(shí)驗(yàn)證
這篇文章主要介紹了Bootstrap實(shí)現(xiàn)input控件失去焦點(diǎn)時(shí)驗(yàn)證的相關(guān)資料,非常不錯(cuò),需要的朋友可以參考下,需要的朋友可以參考下2016-08-08純js代碼制作的網(wǎng)頁時(shí)鐘特效【附實(shí)例】
下面小編就為大家?guī)硪黄僯s代碼制作的網(wǎng)頁時(shí)鐘特效【附實(shí)例】。小編覺得聽錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-03-03uni-app小程序沉浸式導(dǎo)航實(shí)現(xiàn)的全過程
在跨端項(xiàng)目開發(fā)中,uniapp是個(gè)不錯(cuò)的框架,下面這篇文章主要給大家介紹了關(guān)于uni-app小程序沉浸式導(dǎo)航實(shí)現(xiàn)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-10-10利用Javascript實(shí)現(xiàn)一套自定義事件機(jī)制
隨著web技術(shù)發(fā)展,使用JavaScript自定義對(duì)象愈發(fā)頻繁,讓自己創(chuàng)建的對(duì)象也有事件機(jī)制,通過事件對(duì)外通信,能夠極大提高開發(fā)效率。下面這篇文章主要給大家介紹了關(guān)于利用Javascript實(shí)現(xiàn)一套自定義事件機(jī)制的相關(guān)資料,需要的朋友可以參考下。2017-12-12js判斷樣式className同時(shí)增加class或刪除class
用正則表達(dá)式判斷多個(gè)class之間是否存在真正的class(前后空格的處理)然后增加class刪除class,本文給予實(shí)現(xiàn)方法,感興趣的朋友可以了解下,或許對(duì)你有所幫助2013-01-01