웹마스터 팁
page_full_width">
텍스트 선택하기
2006.09.06 19:05
클릭하면 해당 태그 안에 있는 텍스트를 선택해줍니다.
function selectThis(obj) {
if (window.getSelection) {
window.getSelection().selectAllChildren(obj);
} else if (document.body.createTextRange) {
var r = document.body.createTextRange();
r.moveToElementText(obj);
r.select();
}
}
사용예제는…
__________________________________
선택안된 글 <span onclick="selectThis(this)">Select this!</span> 선택되지 않은 글
__________________________________
끝.
원문 : http://mygony.com/archives/874
function selectThis(obj) {
if (window.getSelection) {
window.getSelection().selectAllChildren(obj);
} else if (document.body.createTextRange) {
var r = document.body.createTextRange();
r.moveToElementText(obj);
r.select();
}
}
사용예제는…
__________________________________
선택안된 글 <span onclick="selectThis(this)">Select this!</span> 선택되지 않은 글
__________________________________
끝.
원문 : http://mygony.com/archives/874