zoukankan      html  css  js  c++  java
  • 核桃说笔记

    点击展开看更多内容的效果:
    <div class="ht_div14">
    <div class="ht_div15">
    <p class="ht_p19">
    <img src="{$answerx['author_avartar']}" class="ht_img17" />
    <img src="{SITE_URL}static/pc/img/sy14.png" class="ht_img18" style="display:none" />
    </p>

    <div class="ht_div16">
    <div class="ht_div17">
    <p class="ht_p20">{$answerx['author']}</p>
    <!--<p class="ht_p21"></p>
    <p class="ht_p22">{$answerx['author_groupname']}</p>-->
    </div>

    <p class="ht_p23">
    <span>{$answerx['time']}</span>
    </p>
    </div>
    </div>

    <div class="ht_p25">
    <div class="ht_p25_yincang">
    部分内容。。。。。。
    </div>
    <p class="ht_p46">
    <span>展开全部</span>
    <img src="{SITE_URL}static/pc/img/sy07.png" />
    </p>
    </div>


    </div>

    <script type="text/javascript"> /*点击展开全部效果*/ $(function() { $(".ht_div14").each(function() { var hh = $(this).find(".ht_p25").height(); var zk = $(this).find(".ht_p46").html(); if(hh > 400&&zk) { $(this).find(".ht_p25").css("max-height", "400px"); $(this).find(".ht_p25 .ht_p46").show(); } }) }) $(".ht_p46").on("click", function() { $(this).hide(); $(this).parents(".ht_p25").css("max-height", "none"); }) </script>

    搜索关键词高亮显示:公共方法

    //srl 7-23 搜索覌點,覌點高亮变色修改
    function highlightDesc($content, $words, $highlightcolor = 'red') {
        $wordlist = explode ( " ", $words );
        foreach ( $wordlist as $hightlightword ) {
            if (strlen ( $content ) < 1 || strlen ( $hightlightword ) < 1) {
                return $content;
            }
            $content = preg_replace ( "/$hightlightword/is", "<font color=#D5615B><strong>\0</strong></font>", $content );
        }
        return $content;
    }

    使用方法:控制器方法:使用上面方法进行高亮显示

        //关键词搜索
        function get_by_likename($word, $start = 0, $limit = 6) {
            $topiclist = array ();
    
            $query = $this->db->query ( "SELECT * FROM " . $this->db->dbprefix . "answer WHERE content like '%$word%' order by id desc LIMIT $start,$limit" );
    // var_dump($query->result_array ());die;
            foreach ( $query->result_array () as $topic ) {
                $topic ['title'] = checkwordsglobal ( $topic ['title'] );
                $topic ['describtion'] = checkwordsglobal ( $topic ['content'] );
                $topic ['title'] = highlightDesc ( $topic ['title'], $word );
    $topic ['describtion'] = highlightDesc (  strip_tags ( $topic ['content'] ), $word );$topiclist [] = $topic;
            }
    
            return $topiclist;
        }
    剥去字符串中的 HTML 标签:
    strip_tags

    页面中使用topiclist 函数遍历显示在页面中即可

     

  • 相关阅读:
    想要学习编程?不如来玩玩这15款游戏!总有一款适合你!
    C++ 高级教程:C++ 文件和流
    4个小众Chrome插件,最后一个互联网人必备!
    程序员必读,熬夜是如何摧残你的身体的!
    教育部将编程教育纳入中小学相关课程,编程正成为全球语言!
    Windows 比 Linux 好?我有 13 个反对理由
    程序员的十八般兵器库,捋一捋这近几年程序员们日常工作中常用的开源工具
    how to train yolov4 on custom dataset
    How to Perform Object Detection With YOLOv3 in Keras
    YOLOv4 / Scaled-YOLOv4 / YOLO
  • 原文地址:https://www.cnblogs.com/yszr/p/10736344.html
Copyright © 2011-2022 走看看