Ajax请求数据
$.ajax({
url: "/p/content/city",
type: "GET",
dataType: 'JSON',
data: {
city: name,
},
async: true,
success: function (data) {
//do something here
}
});
DOM
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函数为removeCity()
item.onclick = function () {
removeCity(this);
}
lists.appendChild(item);
操作基础组件
获得checkbox状态
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 + '时';
};
网友评论