JQuery 翻页小记

代码头部要引用JQuery框架

{include file="header.tpl"} 
{include file="side.tpl"}
            <!--内容-->
            <div class="right_content1">
                <div class="title"><img src="templet/{$_sun[tplname]}/images/pp_{$cates[0]}.jpg" /></div>
                <div class="zs_main">
                    {if $result[itemid] == 75}
                    <div class="zn_text">
                       {else}
                       <div class="zc_text">
                       {/if}
                           <h3>{$result[content][subject]}</h3>
                           <ul id="shownav_con">
                           {loop $result[contents][txts] $k $lst}
                               <li id="li_{$k}" class="lili" {if $k} style="display:none;"{/if}>{$lst}</li>
                           {/loop}
                           </ul>
                           <input type="hidden" id="showval" value="0" />
                           <input type="hidden" id="showvalmax" value="{$k}" />
                           <span style="float: right; margin: 10px 0; width: 230px;">
                               <span id="aaa" style="width: 70px;">第 1/<?php echo count($result[contents][txts]); ?> 页</span>
                               <a href="javascript:showhide('0');">首页</a>
                               <a href="javascript:showhide('1');">上一页</a>
                               <a href="javascript:showhide('2');">下一页</a>
                               <a href="javascript:showhide('3');">尾页</a>
                           </span>
                    </div>
                </div>
            </div>
            <!--内容-->
        </div>
    </div>
</div>
<script type="text/javascript"">
function showhide(id){   
    var aid=$('#showval').val();    
    var aidmax=$('#showvalmax').val();
    $(".lili").hide();
    if(id == '0'){ 
        aid = 0;
    }
    if(id == '1'){ 
        if(aid > 0)
        {
            aid = parseInt(aid) - 1;
        }
    }
    if(id == '2'){ 
        if(parseInt(aid) < parseInt(aidmax))
        {
            aid = parseInt(aid) + 1;
        }
    }
    if(id == '3'){
        aid = aidmax;
    }
    $("#aaa").html("第 "+(parseInt(aid)+1)+"/"+(parseInt(aidmax)+1)+" 页");
    $('#li_'+aid).show();
    $('#showval').val(aid);
}

</script>
{include file="footer.tpl"}

 

 

posted @ 2012-08-20 17:26  博尔特希  阅读(186)  评论(0编辑  收藏  举报