我在尝试在 jQuery 中使用 prependTo() 函数时遇到问题......由于某种原因我无法让它工作
$("
<div id="note178" class="note">
<div class="delete"><a href="/chart-notes/delete/178" onclick="$.ajax({ dataType: 'script', url: '/chart-notes/delete/178'}); return false;"><img src='/images/icons/delete.png'></a></div>
<div class="timestamp">1 minute ago </div>
<div class="content">ñasdas dasdasdasd conclusión</div>
</div>
").prependTo(".notes").fadeIn("slow");
虽然这样做时,它工作正常
$.ajax({
url:'/chart-notes/show/<cfoutput>#chartnote.id#</cfoutput>',
success: function(data) {
$(data).prependTo(".notes").fadeIn("slow");
// Scroll to the top of the annotations
$('html, body').animate({scrollTop: $(".notes").offset().top}, 1000);
// Clear the form
$('#chartnote-notes').val("");
}
});
该成功函数的“数据”响应是相同的
<div id="note178" class="note">
<div class="delete"><a href="/chart-notes/delete/178" onclick="$.ajax({ dataType: 'script', url: '/chart-notes/delete/178'}); return false;"><img src='/images/icons/delete.png'></a></div>
<div class="timestamp">1 minute ago </div>
<div class="content">ñasdas dasdasdasd conclusión</div>
</div>
像之前一样