突出显示文本区域内的文本

是否可以使用javascript突出显示文本区域内的文本?只是更改部分文本区域的背景还是选择部分文本?



繁花如伊
浏览 435回答 3
3回答

holdtom

我为此编写的简单脚本:Jsfiddle选项:可选的字符计数器。突出显示几种不同颜色的图案。正则表达式。将匹配项收集到其他容器。简单的样式:字体颜色和字体,背景,边框半径和线高。Ctrl + Shift键可更改方向。//include function like in the fiddle!//CREATE ELEMENT:create_bind_textarea_highlight({&nbsp;&nbsp; &nbsp; &nbsp;eleId:"wrap_all_highlighter",&nbsp; &nbsp; &nbsp;width:400,&nbsp; &nbsp; &nbsp;height:110,&nbsp; &nbsp; &nbsp;padding:5,&nbsp;&nbsp; &nbsp; &nbsp;background:'white',&nbsp; &nbsp; &nbsp;backgroundControls:'#585858',&nbsp; &nbsp; &nbsp;radius:5,&nbsp; &nbsp; &nbsp;fontFamilly:'Arial',&nbsp; &nbsp; &nbsp;fontSize:13,&nbsp; &nbsp; &nbsp;lineHeight:18,&nbsp; &nbsp; &nbsp;counterlettres:true,&nbsp; &nbsp; &nbsp;counterFont:'red',&nbsp; &nbsp; &nbsp;matchpatterns:[["(#[0-9A-Za-z]{0,})","$1"],["(@[0-9A-Za-z]{0,})","$1"]],&nbsp; &nbsp; &nbsp;hightlightsColor:['#00d2ff','#FFBF00'],&nbsp; &nbsp; &nbsp;objectsCopy:["copy_hashes","copy_at"]&nbsp; &nbsp; &nbsp;//PRESS Ctrl + SHIFT for direction swip!&nbsp; });&nbsp;//HTML EXAMPLE:&nbsp;<div id="wrap_all_highlighter" placer='1'></div>&nbsp;<div id='copy_hashes'></div><!--Optional-->&nbsp;<div id='copy_at'></div><!--Optional-->玩得开心!
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript