zoukankan      html  css  js  c++  java
  • web 开发之js---js 实现文本高亮

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>文字高亮</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script language="javascript">
    function init() {

    var keys = new Array("aa", "bb", "cc");

    var keysOther = new Array("11", "22", "33");

    var reblog = eval("/("+keys.join('|')+")/gi");

    document.getElementById("title").innerHTML = document.getElementById("title").innerHTML.replace(reblog,"<font color=red>$1</font>");
    document.getElementById("summary").innerHTML = document.getElementById("summary").innerHTML.replace(reblog,"<font color=red>$1</font>");

    var reblogOther = eval("/("+keysOther.join('|')+")/gi");

    document.getElementById("title").innerHTML = document.getElementById("title").innerHTML.replace(reblogOther,"<font color=yellow>$1</font>");
    document.getElementById("summary").innerHTML = document.getElementById("summary").innerHTML.replace(reblogOther,"<font color=yellow>$1</font>");
    }



    </script>

    </head>

    <body>
    <button onclick="init()">xxxxxxx</button>
    <table width="100%" height="100%">
    <tr>
    <td id="title">
    asdasdflsajdfaafdsfjbbfdsffecc11sdfsssscc22222sdfs333
    </td>
    </tr>
    <tr>
    <td id="summary">
    asdasdflsajdfaafdsfjbbfdsffecc11sdfsssscc22222sdfs333
    </td>
    </tr>
    </table>
    </body>
    </html>

    http://blog.csdn.net/whumr1/article/details/6760746

  • 相关阅读:
    简单工厂设计模式
    MVC备忘
    在MVC后台代码中想实现删除时弹出"确认删除"效果
    集合
    嵌套
    整理 补课内容
    百鸡百钱
    ////输入一个100以内的数,判断是不是正整数;
    课后题 5 6
    课后题3,4
  • 原文地址:https://www.cnblogs.com/pengkunfan/p/4040374.html
Copyright © 2011-2022 走看看