douhao2856 2015-11-18 05:26
浏览 51

在codeigniter中突出显示textarea中的文本

I tried to highlight specific words in string in textarea using codeigniter. My input is $string=array(); $highlight=array();

foreach($highlight as $k=>$v)
    {

        foreach($v as $n)
        {
         $string['word']= highlight_phrase($string['word'], $n, '<span style="color:#990000">', '</span>');

        }  
        }
$data[] ='<div class="Popup"><a href="#megssage"  onclick="show_pop(\''.str_replace('\'', '\\\'', $string['words']).'\')"><i class="fa fa-comment-o"></i></a>
        <textarea name="txtwords[]" class="PopupText" id="txtwd" readonly="readonly" onDblClick="ToggleReadOnlyState('.$string['id'].')" >'.$string['word'].'</textarea></div>';

I have used the above $string['word'] in text area but instead of highlighted text i am getting output as <span style="color:#990000">Good</span> Articel Good is the word to be highlighted exists in variable $highlight=array();.

  • 写回答

1条回答 默认 最新

  • dszdiavv474681 2015-11-18 05:44
    关注

    You have to include jQuery highlightTextarea plugin.

    And try like this:

    <textarea cols="50" rows="5">Lorem ipsum hello  </textarea>
    
    <script>
      $('textarea').highlightTextarea({
        words: ['Lorem ipsum', 'vulputate']
      });
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试