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 函数遍历显示在页面中即可

     

  • 相关阅读:
    数据库的存储过程、数据库设计范式、数据库关系
    谈谈窗体之间的数据交互
    hdu2141AC代码分享
    参考C++STL标准库中对了的使用方法
    背包类问题解答——poj3624分析
    ACM第一天研究懂的AC代码——BFS问题解答——习题zoj2165
    洛谷——P2483 [SDOI2010]魔法猪学院
    洛谷——P2822 组合数问题
    COGS——T 2739. 凯伦和咖啡
    洛谷—— P3225 [HNOI2012]矿场搭建
  • 原文地址:https://www.cnblogs.com/yszr/p/10736344.html
Copyright © 2011-2022 走看看