& lt; ! DOCTYPE html>
<meta charset="utf-8"/& gt;
<body>
<script>
Var inp_out=document. GetElementById (" con_value ");
Var btn_cla=document. GetElementsByClassName (" BTN ");
Var div_inr=document. GetElementById (" inner_text ");
The function addText () {
Var op=document. The createElement method (" p ");
Var ob=document. The createElement method (" button ");
Ob. InnerHTML='x';
Ob. SetAttribute (' class ', "btn2");
Op. InnerHTML=inp_out. Value;
Div_inr. The appendChild (op);
Op. The appendChild (ob);
inp_out.valuehttps://bbs.csdn.net/topics/=';
}
The function removeBtn2 () {
Var op2=this. ParentNode;
Op2. ParentNode. RemoveChild ();
}
Btn_cla [0]. Onclick=addText;
Var p1=document. GetElementsByTagName (" p ");
//var b1=p1. GetElementsByClassName (" btn2 ");
for(var i=0; iP1 [I] getElementsByClassName (" btn2 ") [0]. Onclick=function () {
//this. ParentNode. RemoveChild (enclosing parentNode)
The console. The log (this)
}
}
</script>