JQuery中attr()方法在ie11中不兼容
添加时刻功能,运行时在谷歌和火狐浏览器上没有问题,在ie11和edge上,重复的时刻可以被添加
请问怎么解决?
$(".time-items-div .time-item-add").click(function (e) {
var h = $(".time-items-div .time-select-hour").val();
var m = $(".time-items-div .time-select-minute").val();
if (parseInt(h) < 10) {
h = "0" + h;
}
if (parseInt(m) < 10) {
m = "0" + m;
}
var time = h + ":" + m;
var isAdd = false;
$(".time-items-div ul li").each(function (i, e) {
var value = $(e).attr("value");
if (value == time) {
isAdd = true;
}
});
if (!isAdd) {
var li = $("<li value='" + time + "'><a class='time-item'><span class='time-item-title'>" + time + "</span><span class='time-item-remove'></span></a></li>")
$(".time-items-div ul").append(li);
}
});