textarea 에 특정한 문자 넣기
페이지 정보
본문
참고 : http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040202&docId=71785288&qb=7YGs66Gs7JeQ7IScIHNlbGVjdGlvbi5jcmVhdGVSYW5nZQ==&enc=utf8§ion=kin&rank=3&search_sort=0&spq=0&pid=RVGrnc5Y7tlssZxvcHRsssssssh-088857&sid=Us4rCHJvLDQAADtoE2M
<SCRIPT type="text/javascript">
<!--
function $(Element){
return document.getElementById(Element);
}
function set_tag_support(obj, prefix, postfix) {
if (document.getSelection) ts = document.getSelection();
else if (document.selection) ts = document.selection.createRange().text;
else if (window.getSelection) ts = window.getSelection();
if (ts != ""){ //IE
document.selection.createRange().text = prefix + ts + postfix;
}else {
if (obj.selectionStart == obj.selectionEnd){
if(/*@cc_on!@*/false){
obj.focus();
document.selection.createRange().duplicate().text = prefix + document.selection.createRange().duplicate().text + postfix;
document.selection.createRange().select();
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart);
obj.value = s1 + prefix + postfix + s2;
}
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart, obj.selectionEnd);
var s3 = obj.value.substring(obj.selectionEnd);
obj.value = s1 + prefix + s2 + postfix + s3;
}
}
obj.focus();
}
//-->
</SCRIPT>
<TEXTAREA name="memo" id="memo" ROWS="5" COLS="50"></TEXTAREA>
<INPUT TYPE="button" onclick="set_tag_support($('memo'), '111', '2222')" value="확인">
<SCRIPT type="text/javascript">
<!--
function $(Element){
return document.getElementById(Element);
}
function set_tag_support(obj, prefix, postfix) {
if (document.getSelection) ts = document.getSelection();
else if (document.selection) ts = document.selection.createRange().text;
else if (window.getSelection) ts = window.getSelection();
if (ts != ""){ //IE
document.selection.createRange().text = prefix + ts + postfix;
}else {
if (obj.selectionStart == obj.selectionEnd){
if(/*@cc_on!@*/false){
obj.focus();
document.selection.createRange().duplicate().text = prefix + document.selection.createRange().duplicate().text + postfix;
document.selection.createRange().select();
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart);
obj.value = s1 + prefix + postfix + s2;
}
}else{
var s1 = obj.value.substring(0, obj.selectionStart);
var s2 = obj.value.substring(obj.selectionStart, obj.selectionEnd);
var s3 = obj.value.substring(obj.selectionEnd);
obj.value = s1 + prefix + s2 + postfix + s3;
}
}
obj.focus();
}
//-->
</SCRIPT>
<TEXTAREA name="memo" id="memo" ROWS="5" COLS="50"></TEXTAREA>
<INPUT TYPE="button" onclick="set_tag_support($('memo'), '111', '2222')" value="확인">
- 이전글동일한 칼럼값을 가지는 테이블끼리 값들 옮겨 넣기.. 21.02.09
- 다음글기존 요소에 새로운 요소를 추가 하거나 요소를 이동 하고 싶을때 21.02.09
댓글목록
등록된 댓글이 없습니다.