JavaScript实现简单评论功能本⽂实例为⼤家分享了JavaScript实现简单评论功能的具体代码,供⼤家参考,具体内容如下<!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>
var oTxt = ElementById("txt");
var oBtn = ElementById("btn1");
var oUl1 = ElementById("ul1");
var oBox = ateElement("div");
oBox.className = "box";
//创建头像
var oDiv = ateElement("div");
oDiv.className = "touxiang";
oBox.appendChild(oDiv);
var oDiv = ateElement("div");
oDiv.className = "nicheng";
oDiv.innerHTML = "指尖微凉*";
oBox.appendChild(oDiv);
var oDiv = ateElement("div");
oDiv.className = "pinglun";
oDiv.innerHTML = oTxt.value;
oBox.appendChild(oDiv);
var oDiv = ateElement("div");
oDiv.className = "shijian";
var oDate = new Date();
//FullYear
oDiv.innerHTML ="评论时间 "+ FullYear()+"年"+(Month()+1)+"⽉"+Date()+"⽇"+"<a href='javascript:;'>删除</a>";
oBox.appendChild(oDiv);
oUl1.appendChild(oBox);
/*oBox.insertBefore(oUl1,oDiv[0]);*/
var aA = ElementsByTagName("a");
for(var i = 0;i<aA.length;i++)
{
aA[i].onclick=function(){
}
}
}
}
</script>
</script>
</head>
<body>
<h2 align="center">⽹易云热评</h2>
<div id="div1" >
<textarea cols="70" rows="8" id="txt"></textarea><br />
<input type="button" value="评论" id="btn1" />
<ul id="ul1">
</ul>
如何启用javascript功能</div>
</body>
</html>
效果图:
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论