- Select all DIV text with single mouse click
- MDN - Window.getSelection()
- MDN - Selection.collapse()
- MSDN - Using the TextRange Object
- Professional JavaScript for web Developers(Book) - How practical are ranges?
- Ecms-262.pdf - 6
th Edition / June 2015
텍스트 선택
function selectText(containerid) { // MSIE if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); range.select(); // Other } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById(containerid)); window.getSelection().addRange(range); } }
선택된 텍스트 추출
getSelection
var range = window.getSelection(); console.log( range.toString(), range.toLocaleString() );
반응형
'lang > js' 카테고리의 다른 글
Chrome Javascript 유용한 기능 (0) | 2016.11.10 |
---|---|
Javascript 2015, ECMAScript6, ES6 (0) | 2016.10.09 |
javascript public, private, privileged (0) | 2015.10.28 |
자바 스크립트 무료 전자 책 30 (2) | 2014.09.30 |
모바일 Javascript API (0) | 2014.07.29 |