日期:2014-05-20 浏览次数:20744 次
<html> <head> <script> var isEdit = 0; function changeValue(li) { if(isEdit++ != 0) { return false; } var oldValue = li.innerHTML; li.innerHTML = "<input onblur='confirmChange(this)' value='"+oldValue+"'/>"; } function confirmChange(input) { var newValue = input.value; var li = input.parentNode; li.innerHTML = newValue; isEdit = 0; } </script> </head> <body> <ul> <li onclick="changeValue(this)">1</li> <li onclick="changeValue(this)">2</li> <li onclick="changeValue(this)">3</li> </ul> </body> </html>