我想附加一个带有某些类名的跨度。我正在使用 JavaScript MAP来获取类名。这样它就可以附加适当的类名。
我可以使用以下方法获取值:
mymap.get(value.status)
但我可以,但我无法使用 span 作为类名传递,例如:
<span class...
function refresh() {
var $table = $("table#mytable");
$.getJSON("//127.0.0.1:8001/get_latest_verification", function (obj) {
$.each(obj, function (key, value) {
var mymap = new Map();
mymap.set('Registered', 'badge badge-info');
mymap.set('Tampered', 'badge badge-important');
mymap.set('Verified', 'badge badge-success');
mymap.set('Void', 'badge badge-inverse');
mymap.set('Released', 'badge badge-inverse');
var state = mymap.get(value.status)
var rows = "";
rows = rows + "<tr>" + "<td>" + value.asset_code + "</td>" + "<td>" + value.scan_time + "</td>" + "<td>" + value.credential + "</td>" + "<td>" + "<span class='state'>" + value.status + "</span>" + "</td>" + "<td>" + value.operator + "</td>" + "<td>" + value.location + "</td>" + "<td>" + value.auth_code + "</td>" + "<td>" + value.emp_id + "</td>" + "</tr>";
$table.prepend(rows);
});
});
}