<!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>关键字搜索高亮显示</title> <style> .btn { background: #f6ad3a; border: none; color: #fff; cursor: pointer; display: inline-block; font-family: "Microsoft Yahei"; font-size: 12px; height: 32px; line-height: 32px; margin: 0 1px 0 0; padding: 0 20px; } .keyword { display: block; float: left; margin: 0; padding: 0 5px; width: 110px; height: 30px; line-height: 28px; font-size: 12px; border: 1px solid #dbdbdb; color: #444; } </style></head><body> <div style=" margin-left:40%;"> 输入关键字:<input type="text" class="keyword" value="" id="txtKeywords" /><a class="btn" href="javascript:void(0)" onclick="SearchClick()">搜索</a> </div> <div style=" margin-left:40%;"> <input type="checkbox" value="1" name="ra" id="chkUp" />匹配大小写 </div> <div id="content"> <div style="width: 100%; line-height: 160%; padding: 0 0 0 10%; font-size: 16px;" id="geci"> <div id="T_0" > When You Are Gone --avril(艾薇儿)</div> <div id="T_17"> I always needed time on my own</div> <div id="T_22"> I never thought </div> <div id="T_23"> I'd need you there when I cried</div> <div id="T_30"> And the days feel like years </div> <div id="T_33"> when I'm alone</div> <div id="T_35"> And the bed where you lie</div> <div id="T_38"> Is made up on your side</div> <div id="T_44"> When you walk away</div> <div id="T_46"> I count the steps that you take</div> <div id="T_50"> Do you see how much I need you right now?</div> <div id="T_56"> When you're gone</div> <div id="T_59"> The pieces of my heart </div> <div id="T_61"> are missing you</div> <div id="T_63"> When you're gone</div> <div id="T_65"> The face I came to know </div> <div id="T_68"> is missing too</div> <div id="T_70"> When you're gone</div> <div id="T_72" > The words I need to hear </div> <div id="T_74" > to always get me through the day</div> <div id="T_79" > And make it ok</div> <div id="T_83" > I miss you</div> <div id="T_98" > I never felt this way before</div> <div id="T_103" > Everything that I do</div> <div id="T_106" > reminds me of you</div> <div id="T_111" > And the clothes you left</div> <div id="T_113" > are lyin' on the floor</div> <div id="T_116" > And they smell just like you</div> <div id="T_119" > I love the things that you do</div> <div id="T_125" > When you walk away</div> <div id="T_128" > I count the steps that you take</div> <div id="T_131" > Do you see how much </div> <div id="T_133" > I need you right now?</div> <div id="T_138" > When you're gone</div> <div id="T_140" > The pieces of my heart </div> <div id="T_143" > are missing you</div> <div id="T_144" > When you're gone</div> <div id="T_147" > The face I came to know </div> <div id="T_149" > is missing too</div> <div id="T_151" > When you're gone</div> <div id="T_153" > The words I need to hear </div> <div id="T_155" > to always get me through the day</div> <div id="T_160" > And make it OK</div> <div id="T_164" > I miss you</div> <div id="T_167" > We were meant for each other</div> <div id="T_170" > I keep forever</div> <div id="T_174" > I know we were</div> <div id="T_179" > All I ever wanted was for you to know</div> <div id="T_182" > Everything I do I give my heart and soul</div> <div id="T_186" > I can hardly breathe </div> <div id="T_187" > I need to feel you here with me</div> <div id="T_191" > Yeah</div> <div id="T_192" > When you're gone</div> <div id="T_194" > The pieces of my heart are missing you</div> <div id="T_198" > When you're gone</div> <div id="T_201" > The face I came to know </div> <div id="T_203" > is missing too</div> <div id="T_205" > When you're gone</div> <div id="T_207"> The words I need to hear </div> <div id="T_209" > to always get me through the day</div> <div > And make it OK</div> <div id="T_218"> I miss you </div> </div> </div></body></html><script> function InitialKeywordsShow(_keywords, obj, caseTrue) { //var reg = new RegExp(_keywords, "g");//区分大小写 var reg = new RegExp(_keywords, "gi"); //不区分大小写 if (caseTrue) { var reg = new RegExp(_keywords, "g"); } if (obj && obj.childNodes && obj.childNodes.length > 0) { for (var i = 0; i < obj.childNodes.length; i ) { if (obj.childNodes[i].nodeType == 3 && obj.childNodes[i].nodeValue && obj.childNodes[i].nodeValue.length > 0) { var txtnew = obj.childNodes[i].nodeValue.replace(reg, "<font color='red' style=' background:#e48b00;color:#fff;'>" _keywords "</font>"); var _span = document.createElement("span"); _span.innerHTML = txtnew; obj.replaceChild(_span, obj.childNodes[i]); } else if (obj.childNodes[i].nodeType == 1) { InitialKeywordsShow(_keywords, obj.childNodes[i], caseTrue); } } } } function SearchClick() { var fonts = document.getElementsByTagName("font"); if (fonts && fonts.length > 0) { for (var i = 0; i < fonts.length; i ) { fonts[i].style.backgroundColor = "#fff"; fonts[i].style.color = "black" } } var keyWords = document.getElementById("txtKeywords").value; var obj_content = document.getElementById("content"); if (!keyWords) { alert("请输入关键字"); return false; } var upTrue = document.getElementById("chkUp").checked; InitialKeywordsShow(keyWords, obj_content, upTrue); }</script>
下载js实现关键字高亮用户还喜欢
- 18480 文章数
- 500万+ 热度
作者专栏
编辑推荐
- 淡抹u2引擎,修复内容较多,物有所值
- 界域传说·经典巨作=传世单机(一键安装)
- 丸子版本(175个传世版本大集合)
- GS版本:神话公益服务端+客户端
- 图片放大工具(放大图片不模糊)
- 剪映无限制VIP版
- 传奇世界客户端下载器,史上最全传世客户端
- 传世GS20220920商业引擎注册+登录配置器 解压密码是1
- U2官方排行榜游戏网关 支持元神,支持传家宝
- GS开战传世客户端+服务端
- (淡漠夕阳)u2引擎合区工具
- 传世GS引擎消除“你的游戏客户端版本号过旧,请及时更新”提示
- 传世一机多区双线路配置器--免密码版本
- 传世凤凰登陆器劫持修复软件
- SQLite3 for Navicat
- 传奇世界npc对话框编辑工具
- 传世GS落霞铭文服务器端
- gs_20210409引擎包+注册机(无限制)
- 传奇世界NPC对话封包查看器[支持时长版和极速版]
- 彩虹引擎传世脚本编辑工具1.7版来了,支持函数脚本翻译
评论