autojs微博_js实现微博发布小功能
微博發(fā)布功能,可發(fā)布可刪除。樣式?jīng)]設(shè)置忽略,主要知識(shí)點(diǎn)及注意點(diǎn):
1、動(dòng)態(tài)添加節(jié)點(diǎn)標(biāo)簽。
2、內(nèi)容為空時(shí)不能發(fā)布。
3、新發(fā)布的內(nèi)容要在上面。
4、內(nèi)容刪除要同時(shí)刪除掉節(jié)點(diǎn)。
5、為保持樣式輸入框要設(shè)置為不可拖拽。
Document* {margin: 0;padding: 0;}
.box{
border: 1px solid #000;
width: 600px;
height: auto;
margin:100px auto;
padding:30px 0;
}
textarea{
width: 450px;
resize:none;
margin-left: 20px;
}
ul li{
width: 450px;
list-style: none;
border-bottom: 1px dotted #ccc;
margin-left:20px;
line-height: 30px;
color: #333;
}
ul li a{
float: right;
font-size: 12px;
}
// 方法1
window.onload = function () {
var box = document.getElementById("box");
var boys=box.children;
var ul = document.createElement("ul");
box.appendChild(ul);
boys[2].onclick = function (){
if(boys[1].value==""){
alert("輸入不能為空");
return;
}
var newli= document.createElement("li");
newli.innerHTML=boys[1].value+"刪除";
boys[1].value ="";
var lis=ul.children;
if(lis.length==0){ul.appendChild(newli);}else{
ul.insertBefore(newli, lis[0]);
}
var as=document.getElementsByTagName("a");
for (var i=0;i
as[i].οnclick=function(){
ul.removeChild(this.parentNode);
}
}
}
}
// 方法2 引用jQuery
// $(function(){
// $("
// var $text = $("#box").find("textarea");
// var $btn = $("#box").find("button");
// $btn.on("click",function(){
// if($text.val() ==""){
// alert("請(qǐng)輸入內(nèi)容");
// return;
// }
// $("ul").prepend("
"+$text.val()+"刪除");// $text.val("");
// $("a").on("click",function(){
// $(this).parent("li").remove();
// })
// })
// })
微博發(fā)布:
發(fā)布
以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!
總結(jié)
以上是生活随笔為你收集整理的autojs微博_js实现微博发布小功能的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: findviewbyid找不到id_上班
- 下一篇: 1一9数字行书写法_EduOffice数