Javascript examples for DOM HTML Element:Div
Focus editable div
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w.ja va2s .c om var sel = window.getSelection(); var innerDiv = document.getElementById("innerKey"); var innerDivText = innerDiv.firstChild; sel.collapse(innerDivText, 0); innerDiv.parentNode.focus(); } </script> </head> <body> <div contenteditable="true" class="key"> <div id="innerKey"> 276 </div> </div> </body> </html>