function sel() { var ta=document.getElementById('textareaid'); alert(ta.value.substring(ta.selectionStart, ta.selectionEnd));}