var cityName = document.getElementById("city_field").value;
var item = document.createElement("li")
item.innerHTML = cityNameCH;
var fa = document.createElement("i");
fa.className = "fa fa-li fa-minus";
item.appendChild(fa);
//設置onclick函數(shù)為removeCity()
item.onclick = function () {
removeCity(this);
}
lists.appendChild(item);
操作基礎組件
獲得checkbox狀態(tài)
var checked = item.checked
時間format
function formatDateTime(inputTime) {
var date = new Date(inputTime);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
return y + '-' + m + '-' + d + ' ' + h + '時';
};