<div class="weui-cell" style="display: none;" id="addtimes"> <div style="font-size: 14px;color:blue;" id="addnewtime">+新增提醒時間</div> </div>
//點擊新增html
$("#addnewtime").click(function () { var html = "<div class='weui-cell'>" + "<div class='weui-weui-cell__hd'><label class='weui-label'>提醒時間:</label></div>"+ "<div class='weui-cell__bd'><input class='weui-input' type='datetime-local' name='times[]' /></div>" + "<div style='color: green' onclick='deleteTime(this)'>刪除</div>" + "</div>"; $("#alertTimes").after(html); });
//刪除點擊事件(obj在這至關於this,須要使用$(obj)來調用)ui
//刪除時間
function deleteTime(obj) {
$(obj).parent().remove();
}