我有一个div,里面放了一个带有提交按钮的文本域。我需要把这个文本域放在每篇文章下面,以便让用户发表评论。
以下是我的文本域的样式:
当我使用Jquery获取div textarea_wrap的innerHTML,并将其移动到其他div时,它会停止工作。
例如:
它成功地将“textarea_wrap” div的内部HTML移动到“#comment_10 div”,当我使用jQuery移动div后查看源代码时,它看起来像这样。
以下是我的文本域的样式:
<div id="textarea_wrap">
<div id="textarea_12" class="txtarea">
<form name="post_comment" action="reply.php" method="post">
<input type="hidden" name="post_title" value="Post Title" />
<input type="hidden" name="post_id" value="12455" />
<textarea class="textarea" id="txt_12"></textarea>
<input type="submit" class="button" value="Submit Comment />
</form>
</div>
</div>
当我使用Jquery获取div textarea_wrap的innerHTML,并将其移动到其他div时,它会停止工作。
例如:
var txtarea = $("#textarea_wrap").html();
$("#comment_10").html(txtarea);
它成功地将“textarea_wrap” div的内部HTML移动到“#comment_10 div”,当我使用jQuery移动div后查看源代码时,它看起来像这样。
<div id="comment_10">
<div id="textarea_12" class="txtarea">
<form name="post_comment" action="reply.php" method="post">
<input type="hidden" name="post_title" value="Post Title" />
<input type="hidden" name="post_id" value="12455" />
<textarea class="textarea" id="txt_12"></textarea>
<input type="submit" class="button" value="Submit Comment />
</form>
</div>
</div>
但是当我点击“提交评论”按钮时,它不起作用。如果我在不使用jQuery的情况下使用此代码,则可以正常工作。不明白为什么通过jQuery移动后它不能工作。