如何在表格中顯示時將我的JSON文件中的URL值設置爲超鏈接?JSON文件中的超鏈接URL值
JSON
{
"one": "http://urltovideo.mp4",
"two": "The second list item",
"three": "The third list item"
}
jQuery的
$.getJSON("test.json", function(data) {
var items = [];
$.each(data, function(key, val) {
items.push("<div class='panel panel-default'><div class='panel-heading'>" + key + "</div><div
class='panel-body'><a href=''>" + val + "</a></li></div></div>");
});
$("<ol/>", {
"class": "my-new-list",
html: items.join("")
}).fadeIn(900).appendTo("body");
});
你只需要更緩慢地走一點點就行items.push。也許你想在這之前有一個if語句來分離出超鏈接? – ControlAltDel 2014-09-05 14:30:47
[是不是那些超鏈接已經?](http://jsfiddle.net/1L7hf6L5/) – 2014-09-05 14:39:52