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
>
查看全文
相关阅读:
Djang下载虚拟环境设置
数据类型和变量
zedboard如何从PL端控制DDR读写(三)——AXI-FULL总线调试
zedboard如何从PL端控制DDR读写(二)——AXI总线
zedboard如何从PL端控制DDR读写(一)
用python3统计代码行数
内存电路分析-设计框图和金手指
钢铁侠也要换成女版的了???
【转】DDR3详解(以Micron MT41J128M8 1Gb DDR3 SDRAM为例)
verilog中符号位的扩展问题
原文地址:https://www.cnblogs.com/think/p/328907.html
最新文章
Python3-2020-测试开发-15- lambda函数&eval()函数&递归
ADB命令-1-adb常用命令
Jmeter接口自动化-13-断言
前端之jQuery
前端之BOM,DOM
前端之javaScript
前端之css
前端之HTML
数据库5
数据库6
热门文章
数据库3
数据库4
数据库1
middleware
git 使用 gitignore
js 字符串格式化
Django paginator and Form
Django templates and models
mysql 连接 django
Django
Copyright © 2011-2022 走看看