摘要: 背景: 在最近项目中,碰到一个问题:有一个可编辑的div需要双击时可编辑,blur或者回车时将编辑结果保存。你可能注意到双击时,文字会被选中,可编辑区域不会focus到光标位置。考虑到兼容性问题,写了如下代码。做个备份,以备不时之需。js: 1 function getMouseEventCaretRange(evt) { 2 3 var range, x = evt.clientX, y = evt.clientY; 4 5 // Try the simple IE way first 6 if (document.body.cr... 阅读全文
posted @ 2013-07-27 22:15 城池 阅读(867) 评论(0) 推荐(1) 编辑