第一种方法:
<div οnclick="aaa(this)">999</div>
function aaa(box) {
box.outerHTML="<input οnblur='bbb(this)' autofocus='autofocus' type='text' value='"+box.innerHTML+"' />"
}
function bbb(box) {
box.outerHTML='<div οnclick="aaa(this)">'+box.value+'</div>'
}
第二种方法:
<div οnclick="aaa(this)">999</div>
function aaa(box) {
var inp = document.createElement("input");
inp.value = box.innerHTML;
inp.onblur = function () {
bbb(inp)
};
inp.focus()
document.getElementsByTagName("body")[0].repla
<div οnclick="aaa(this)">999</div>
function aaa(box) {
box.outerHTML="<input οnblur='bbb(this)' autofocus='autofocus' type='text' value='"+box.innerHTML+"' />"
}
function bbb(box) {
box.outerHTML='<div οnclick="aaa(this)">'+box.value+'</div>'
}
第二种方法:
<div οnclick="aaa(this)">999</div>
function aaa(box) {
var inp = document.createElement("input");
inp.value = box.innerHTML;
inp.onblur = function () {
bbb(inp)
};
inp.focus()
document.getElementsByTagName("body")[0].repla