$("#addtemplate").click(function () { //新增模板
var liEl = document.createElement('li');
var aEl = document.createElement('a');
aEl.contentEditable = true;
aEl.classList.add("aaa");
$(aEl).bind('keydown', function (event) {
if (event.keyCode == "13") {
event.preventDefault();
aEl.contentEditable = false;
$(aEl).unbind();
}
});
aEl.onclick = function () {
var self = this;
currentTemplate.el = liEl;
if (self.contentEditable === 'false') { //aEl.contentEditable 是false,!aEl.contentEditable还是false
console.log(self.contentEditable)
$("#wbs-window").attr("src", "wbsEdit.html");
openWBSWindow(self.proData);
}
}
元素的contentEditable是判断这个元素是否可编辑,但是获取到它的值时,这个值的类型是字符串,而不是布尔,所以在判断的时候要写成元素.contentEditable === 'false' 或者‘true’。