小弟的jquery刚学,很多都不太清楚,自己做的页面上点击发表留言后,生成留言框和回复按钮,但是在点击回复没反应,哪位大神看看是哪里出问题了,
<br> * {<br> padding: 0;<br> margin: 0;<br> }</p> <pre><code> li { list-style: none; } #parent { width: 600px; margin: 0 auto; } h4 { line-height: 40px; margin-bottom: 10px; border-bottom: 1px solid #333; color: #FF3300 } p { width: 100%; background: #f1f1f1; position: relative; margin-bottom: 25px; } #box { width: 580px; padding: 25px 10px 0; border: 1px solid #ddd; margin-bottom: 10px; } span { position: absolute; top: -20px; right: 0px; } em { position: relative; top: -13px; } #text { width: 100%; height: 90px; overflow: auto; } #btn { width: 100%; height: 50px; } </style> <script type="text/javascript"> i = 1; function replay(){ var textarea= $("<textarea/>").css('width','500px').css('height','80px'); var baocun=$("<input type='button' value='保存'/>") .css('width','50px').css('height','30px'); var quxiao=$("<input type='button' value='取消'/>") .css('width','50px').css('height','30px'); //获取当前元素的父节点 var f_div=$(this).parent(); textarea.appendTo(f_div); baocun.appendTo(f_div); quxiao.appendTo(f_div); } function fnsubmit() { var odiv =$("#box"); var oem = $("#em"); var otext = $("#text"); var oli = $("#li"); var add_li = $("<li>"); var o_span = $("<span></span>"); var span1 =$("<span></span>"); if (otext.value == "") { alert("请填写留言内容!"); return; } var str = $("<textarea>").val(otext.val()) .css('width','530px').css('height','80px'); var span1Text = $("<input type='button' value='回复' onclick='replay()'/>") .css('width','50px').css('height','30px'); o_span.appendTo(add_li); o_span.css('display','none'); str.appendTo(add_li); span1Text.appendTo(add_li); add_li.appendTo(odiv); i++; for (j = 0; j < oli.length; j++) { var m = j; oli[j].onmouseover = function () { this.style.background = "#ffff00"; (this.childNodes(o_span)).style.display = "block"; }; oli[j].onmouseout = function () { this.style.background = "#3399FF"; (this.childNodes(o_span)).style.display = "none"; }; oli[j].onclick = function () { m--; odiv.removeChild(this); if (m < 0) { oem.style.display = "block"; } ; }; } ; } </script> <title>留言板</title> </code></pre> <p></head><br> <body></p> <div id="parent"> <h4> 留言内容: </h4> <input type="text" id="text"> <br/> <input id="btn" type="button" onclick="fnsubmit()" value="发表留言"/> <div id="box"> <em>这里会显示留言内容……</em> </div> </div> <p></body><br> </html></p>