$.post("../../Handler/Topic.ashx",
{ commentclob: commentClob,
commenttitle: commentTitle,
topicId: id,
Button: buttoname },
function (data) {
obj = jQuery.parseJSON(data);
var $table = $('<table/>').addClass('commentbox');
$table.append('<tr><td>' +
'Comment Id:' +
obj.CommentId +
'</td></tr>');
var includeReply = "<input type='button'
class='btnReply'
value='Reply'
id='btnReply-" + obj.CommentId + "' />";
$("#commentContainer").prepend(
$('<div/>').attr('id', '#comment-' + obj.CommentId)
.append($table)
);
//This doesnt work
$("#comment-" + obj.CommentId).append(
$('<div/>').attr('id', '#container-' + obj.CommentId)
.append(includeReply)
);
});
html
<div id="commentContainer"></div>
我能够成功地将带有#comment-id 的div 附加到comment-container,但我无法在#comment-id 中附加另一个div。
我试过了
var str = $("<div>").attr("id", "#container-" + obj.CommentId)
$(str).append(includeReply);
$table.append('<tr><td>' + 'CommentDiv:' + str + '</td></tr>');
但它给
CommentDiv:[对象对象]