zoukankan
html css js c++ java
在光标处添加文字,或对选择的文字进行更改(JS:TextRange)
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>
Untitled Page
</
title
>
<
script
language
="javascript"
type
="text/javascript"
>
function
Blod()
{
Format(
"
粗体
"
,
"
'''
"
);
}
function
Italic()
{
Format(
"
斜体
"
,
"
''
"
);
}
function
Format(formatName,format)
{
var
textarea
=
document.getElementById(
"
txaContent
"
);
if
(textarea.pos
!=
null
)
{
var
s
=
textarea.pos.text;
if
(s
==
null
||
s
==
'undefined'
||
s
==
'')
{
s
=
formatName ;
}
s
=
format
+
s
+
format;
textarea.pos.text
=
s;
}
else
{
textarea.value
+=
format
+
formatName
+
format;
}
}
</
script
>
</
head
>
<
body
>
<
textarea
id
="txaContent"
cols
="20"
rows
="20"
onselect
="this.pos = document.selection.createRange();"
onclick
="this.pos = document.selection.createRange();"
onkeyup
="this.pos = document.selection.createRange();"
></
textarea
>
<
input
type
="button"
onclick
="Blod()"
value
="Blod"
id
="btnBlod"
/>
<
input
type
="button"
onclick
="Italic()"
value
="Italic"
id
="btnItalic"
/>
</
body
>
</
html
>
查看全文
相关阅读:
MyBatis学习(三)
MyBatis学习(二)
Linux(Ubuntu)下MySQL的安装与配置
IO 流读取文件时候出现乱码 文件编码格式问题 怎么转换解决方法
spring boot下MultipartHttpServletRequest如何提高上传文件大小的默认值
Mybatis 批量插入时得到插入的id(mysql)
对PDF的操作
利用nginx进行集群部署
Spring boot学习笔记之@SpringBootApplication注解
git的使用命令
原文地址:https://www.cnblogs.com/think/p/328907.html
最新文章
Window 7 安装Docker toolbox , 启动terminal时遇到的小问题
Eclipse插件无法识别的解决方法汇总
for循环 重点题
if 一元二次方程求根
css 下拉菜单
样式表 巩固
Dom 简介
js 函数
if中可以使用那些作为判断条件呢?
格式与布局
热门文章
JavaScript中for循环的使用详解
js 基础
ArrayList的底层实现原理
String、StringBuffer和StringBuilder区别
JVM类加载机制
JVM垃圾回收机制
HashMap和HashTable
Dubbo学习
MyBatis学习(五)
MyBatis学习(四)
Copyright © 2011-2022 走看看