加载更多不工作的jquery

时间:2017-05-12 19:58:10

标签: javascript php jquery wordpress

问题

我试图通过jquery隐藏元素。但是找不到任何原因导致它无法正常工作。我做了一个示例中显示的内容:https://jsfiddle.net/cse_tushar/6FzSb/ 我的网站在哪里可以看到完整的问题:http://bookanytravel.com/hotels-en/ 不要非常强烈地判断我可能忘了放一些jquery插件

代码Html:

<div class="row" id="mixitup">

    <ul id="myList">

        <li class="mix col-sm-6 col-xs-12 stars-<?=$stars?> <?=$emirate?> <?=strtolower(the_title('','',false))?>" data-priceorder="<?=$price_ord?>" data-ratingorder="96" data-starorder="<?=$stars?>">



            <div class="hotel_card">

                <div class="tour_img" style="background-image: url(<?=$photo[0]?>);"></div>

                <div class="price"><?=pll__('from')?> <strong><?=types_render_field("price", array("raw"=>"true"))?></strong></div>



                <div class="tour_info">

                    <h3 class="title"><a href="<?=get_permalink( $post->ID )?>"><? the_title(); ?></a></h3>

                    <div class="category"><?=types_render_field("address", array("raw"=>"true"))?></div>

                    <div class="stars">

                        <? $stars = types_render_field("stars", array("raw"=>"true"));

                        for ($i = 1; $i <= $stars; $i++): ?>

                            <span></span>

                        <? endfor; ?>

                    </div>

                </div>



                <div class="tour_links">

                    <hr>

                    <a data-remodal-target="modal_<?=$post->ID?>" href="#" class="book_tour"><?=pll__('Book the Hotel')?></a>

                    <a href="<?=get_permalink( $post->ID )?>" class="read_more"><?=pll__('Read More')?></a>

                    <hr>

                </div>

            </div>



        </li>

        <div class="col-xs-12"><div class="cd-fail-message alert alert-warning"><?=pll__('Not Found')?></div></div>



    </ul>

                    <!-- <div style="cursor:pointer; text-align: center;font-size: 25px;border: 1px solid;" id="loadMore">Load more</div> -->

Jquery的

$(document).ready(function () {

                size_li = $("#myList li").size();

                x=3;

                $('#myList li:lt('+x+')').show();

                $('#loadMore').click(function () {

                    x= (x+5 <= size_li) ? x+5 : size_li;

                    $('#myList li:lt('+x+')').show();

                });

            });

0 个答案:

没有答案