gpt4 book ai didi

javascript - 从 JSON Href 获取在表中工作的按钮

转载 作者:行者123 更新时间:2023-12-03 11:00:33 25 4
gpt4 key购买 nike

    <table class="pull-left table table-fill">
<thead>
<tr>
<th class="table-hover">Name</th>
<th class="table-hover">Price</th>

</tr>
</thead>
</table>


</body>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>

$.ajax({
type: 'GET',
crossDomain: true,
dataType: 'jsonp',
url: 'api link here',
success: function (json) {
//var json = $.parseJSON(data);
for(var i =0;i < json.results.collection1.length;i++) {
var title = json.results.collection1[i].EventsUK.text;
var href = json.results.collection1[i].EventsUK.href;
$("table").append("<tbody><tr><td>"+title+"</td><td>"+href+"</td></tr></tbody>");
}
},
error: function(error){
console.log(error);
}
});
</script>

我从网站收到了 href。我如何将 href 放入按钮链接中?要显示在同一个位置(表格)。我尝试将所有按钮命令添加到不起作用的代码中,我还尝试将其添加到 href 前面和加号前面。

山姆

最佳答案

HTML 中的链接无法自行解析。您需要使用<a>标签代替。这是非常脏的,但是根据您的代码,最快的技巧是更改您的 append进入

$("table").append(""
+ "<tbody>"
+ "<tr>"
+ "<td>" + title + "</td>"
+ "<td><a href=" + href + ">" + href + "</a></td>"
+ "</td>"
+ "</tr>"
+ "</tbody>"
);

...虽然我不明白该表的含义。

关于javascript - 从 JSON Href 获取在表中工作的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28115172/

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