|
<!DOCTYPE html> |
|
<html> |
|
<head lang="en"> |
|
<meta charset="UTF-8"> |
|
<title>课工场论坛列表</title> |
|
<link href="css/bbs.css" rel="stylesheet"> |
|
<script> |
|
function fa() { |
|
document.getElementById("post1").style.display="block"; |
|
//alert("aaa"); |
|
|
|
} |
|
function touxiang () { |
|
let tou = new Array("tou01.jpg","tou02.jpg","tou03.jpg","tou04.jpg"); |
|
let suiji =parseInt(Math.random()*4); |
|
return tou[suiji]; |
|
} |
|
function chu() { |
|
document.getElementById("post1").style.display="none"; |
|
let s =document.getElementsByTagName("ul")[0]; |
|
let a =document.createElement("li"); |
|
let b =document.createElement("div"); |
|
let c =document.createElement("img"); |
|
let d =document.createElement("h1"); |
|
let e =document.createElement("p"); |
|
let f =document.createElement("span"); |
|
s.appendChild(a); |
|
a.className=".bbs section ul li"; |
|
a.appendChild(b); |
|
b.className = ".bbs section ul li div"; |
|
b.appendChild(c); |
|
c.className = ".bbs section ul li div img"; |
|
c.src = "images/" + touxiang(); |
|
a.appendChild(d); |
|
d.className = ".bbs section ul li h1"; |
|
d.innerHTML = document.getElementById("title").value; |
|
a.appendChild(e); |
|
e.className = ".bbs section ul li p"; |
|
e.innerHTML = "版块:" + document.getElementsByTagName("select")[0].value; |
|
e.appendChild(f); |
|
f.className = ".bbs section ul li p span"; |
|
|
|
/* let title = document.getElementById("title")[0].value; |
|
let Block =document.getElementsByTagName("select")[0].value; |
|
let content =document.getElementsByClassName("content")[0].value;*/ |
|
|
|
let myDate =new Date(); |
|
let Time = myDate.getFullYear() + "-" + (myDate.getMonth()+1)+ "-" + myDate.getDate() + " " + myDate.getHours() + ":" + myDate.getMinutes(); |
|
f.innerHTML = "发表时间:" + Time; |
|
// alert(Time); |
|
|
|
document.getElementById("title").value = ""; |
|
document.getElementsByTagName("select")[0].value = ""; |
|
//document.genElementById("content").value=""; |
|
document.getElementsByClassName("content")[0].value=""; |
|
s.insertBefore(a, s.firstElementChild); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
</head> |
|
<body> |
|
<div class="bbs"> |
|
<header><span onclick="fa()">我要发帖</span></header> |
|
<section> |
|
<ul></ul> |
|
</section> |
|
|
|
|
|
<div class="post" id="post1"> |
|
<input class="title" id="title" placeholder="请输入标题(1-50个字符)"> |
|
所属版块:<select id="Block"><option>请选择版块</option><option>电子书籍</option><option>新课来了</option><option>新手报到</option><option>职业规划</option></select> |
|
<textarea class="content" id="content"></textarea> |
|
|
|
<input class="btn" value="发布" onclick="chu()"> |
|
</div> |
|
</div> |
|
|
|
|
|
|
|
</body> |
|
</html> |