gpt4 book ai didi

javascript - 如何将 html div 附加到表以响应 jQuery getJSON

转载 作者:行者123 更新时间:2023-11-28 09:05:27 25 4
gpt4 key购买 nike

我正在尝试执行以下操作:

$.getJSON("script/course_session.php", data, function(data) {
$.each(data, function(i, item) {

var $tr = $('<tr>').append(
$('<td>').text(item.start_date + " - " + item.end_date),
$('<td>').text(
'<div class=&quot;col-md-3 btn-buy animated fadeInRight&quot;><a href=&quot;#&quot; class=&quot;btn-u btn-u-sm enroll-button&quot;><i class=&quot;fa fa-university&quot;></i> Register</a></div>')
).appendTo("#session-table");
});
});

目的是实现如下目标(我使用的是 Bootstrap):

enter image description here

但是,它是这样打印的: enter image description here

渲染 html 的正确方法是什么?

最佳答案

您必须使用 .html(...) 而不是 .text()。和“而不是引号;

关于javascript - 如何将 html div 附加到表以响应 jQuery getJSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26725870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com