在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ 為什么點(diǎn)擊頁(yè)碼后列表的a標(biāo)簽就無(wú)法跳轉(zhuǎn)了?

為什么點(diǎn)擊頁(yè)碼后列表的a標(biāo)簽就無(wú)法跳轉(zhuǎn)了?

圖片描述

如圖,
列表最右側(cè)的數(shù)字1是一個(gè)a鏈接,點(diǎn)擊可以跳轉(zhuǎn)到新頁(yè)面。
在頁(yè)碼第一頁(yè)時(shí)可以正常跳轉(zhuǎn)。
當(dāng)我點(diǎn)擊到第二頁(yè)時(shí),列表的a鏈接便無(wú)法跳轉(zhuǎn)。再回到第一頁(yè)鏈接也無(wú)法跳轉(zhuǎn)了。
也就是說(shuō)只要點(diǎn)擊頁(yè)碼后,列表里的a鏈接便無(wú)法跳轉(zhuǎn)了。

分頁(yè)用的是laypage,a鏈接換成button也是同樣的問(wèn)題。

請(qǐng)問(wèn)這是什么原因?

function getInfo(page) {

    $.ajax({
        type: 'post',
        url: '/web/illegalMessages',
        //dataType:'json',
        data: {
            'page': page
        },
        async: false,
        success: function(data) {

            //var data = JSON.parse(data);
            var list = data.data;
            totalRow = data.totalRow; //獲取總條數(shù)

            if (data.flag == 'success') {

                $('tbody').html(''); //先清空,否則再次查詢(xún)會(huì)在本頁(yè)累加數(shù)據(jù)

                for (var i = 0; i < list.length; i++) {
                    var num=i+(page-1)*10
                    $('tbody').append(
                        '<tr id="' + list[i].illegalmessageid + '">' +
                        '<td>' + num + '</td>' +
                        '<td>' + list[i].occurarea + '</td>' +
                        '<td>' + list[i].platenumber + '</td>' +
                        '<td>' + list[i].occurtime + '</td>' +
                        '<td>' + list[i].markImgPath + '</td>' +
                        '<td>' + list[i].detailImgPath + '</td>' +
                        '<td>' + list[i].voicePath + list[i].videoPath + '</td>' +
                        '<td>'+
                        '<a href="javascript:;">'+
                         list[i].deal + 
                         '</a>'+
                         '</td>' +
                        '</tr>'
                    )
                }
            }


            //配置并加載所需模塊
            layui.config({
                base: 'base/lay/modules/'
            }).use(['laypage', 'table'], function() {
                var laypage = layui.laypage;
                var table = layui.table;

                //實(shí)例化分頁(yè)
                laypage.render({
                    elem: 'layPage' //分頁(yè)容器的id
                        ,
                    layout: ['prev', 'page', 'next', 'limits', 'count'] //排版
                        ,
                    limit: 10 //每頁(yè)顯示數(shù)
                        ,
                    count: totalRow //總條數(shù)
                        ,
                    curr: page //當(dāng)前頁(yè)
                        ,
                    groups: 3 //連續(xù)出現(xiàn)的頁(yè)數(shù)
                        ,
                    theme: '#1E9FFF' //自定義選中色值
                        ,
                    skip: true //開(kāi)啟跳頁(yè)
                        ,
                    jump: function(obj, first) { //點(diǎn)擊頁(yè)碼跳頁(yè)
                        if (!first) {
                            $('tbody').html('');
                            getInfo(obj.curr); //查詢(xún),傳參:當(dāng)前頁(yè)
                        }
                    }
                });
            });

        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            console.log(XMLHttpRequest.status);
            console.log(XMLHttpRequest.readyState);
            console.log(textStatus);
        },
    })
}


$(function() {

 //存儲(chǔ)id到會(huì)話(huà)并且跳轉(zhuǎn)頁(yè)面
    $('tbody a').unbind('click').on('click',function(){

        var id=$(this).parents('tr').attr("id");

        sessionStorage.setItem('id',id);

        $(this).attr("href","../Illegal_honking/Illegal_honking.html");

    })

})
回答
編輯回答
獨(dú)白

你這個(gè)寫(xiě)法還有問(wèn)題,影響性能。

function getInfo(page) {

$.ajax({
    type: 'post',
    url: '/web/illegalMessages',
    //dataType:'json',
    data: {
        'page': page
    },
    async: false,
    success: function(data) {

        //var data = JSON.parse(data);
        var list = data.data;
        totalRow = data.totalRow; //獲取總條數(shù)

        if (data.flag == 'success') {

            $('tbody').html(''); //先清空,否則再次查詢(xún)會(huì)在本頁(yè)累加數(shù)據(jù)
            var _html = "";
            for (var i = 0; i < list.length; i++) {
                var num=i+(page-1)*10
                _html += '<tr id="' + list[i].illegalmessageid + '">' +
                    '<td>' + num + '</td>' +
                    '<td>' + list[i].occurarea + '</td>' +
                    '<td>' + list[i].platenumber + '</td>' +
                    '<td>' + list[i].occurtime + '</td>' +
                    '<td>' + list[i].markImgPath + '</td>' +
                    '<td>' + list[i].detailImgPath + '</td>' +
                    '<td>' + list[i].voicePath + list[i].videoPath + '</td>' +
                    '<td>'+
                    '<a href="javascript:;">'+
                     list[i].deal + 
                     '</a>'+
                     '</td>' +
                    '</tr>'
            }
            $('tbody').append(_html);
        }


        //配置并加載所需模塊
        layui.config({
            base: 'base/lay/modules/'
        }).use(['laypage', 'table'], function() {
            var laypage = layui.laypage;
            var table = layui.table;

            //實(shí)例化分頁(yè)
            laypage.render({
                elem: 'layPage' //分頁(yè)容器的id
                    ,
                layout: ['prev', 'page', 'next', 'limits', 'count'] //排版
                    ,
                limit: 10 //每頁(yè)顯示數(shù)
                    ,
                count: totalRow //總條數(shù)
                    ,
                curr: page //當(dāng)前頁(yè)
                    ,
                groups: 3 //連續(xù)出現(xiàn)的頁(yè)數(shù)
                    ,
                theme: '#1E9FFF' //自定義選中色值
                    ,
                skip: true //開(kāi)啟跳頁(yè)
                    ,
                jump: function(obj, first) { //點(diǎn)擊頁(yè)碼跳頁(yè)
                    if (!first) {
                        $('tbody').html('');
                        getInfo(obj.curr); //查詢(xún),傳參:當(dāng)前頁(yè)
                    }
                }
            });
        });

    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        console.log(XMLHttpRequest.status);
        console.log(XMLHttpRequest.readyState);
        console.log(textStatus);
    },
})

}

$(function() {

//存儲(chǔ)id到會(huì)話(huà)并且跳轉(zhuǎn)頁(yè)面

$('tbody a').unbind('click').on('click',function(){

    var id=$(this).parents('tr').attr("id");

    sessionStorage.setItem('id',id);

    $(this).attr("href","../Illegal_honking/Illegal_honking.html");

})

})

2017年12月13日 00:50
編輯回答
近義詞

不上代碼,你給我們說(shuō)天書(shū)呢?
1.首屏沒(méi)問(wèn)題,分頁(yè)是異步加載嗎?
2.加載完還是a標(biāo)簽嗎?
2.如果是a標(biāo)簽,href還在嗎?
3.如果href在,是正確的href嗎?
4.信息太少了


修改

在你異步完的ajax里拼接a標(biāo)簽的時(shí)候

<a href="javascript:;">

寫(xiě)死了。
正常的邏輯應(yīng)該是拿到后臺(tái)傳過(guò)來(lái)的地址拼上去,或者有一定的規(guī)則自己拼接。

2017年12月30日 20:19
編輯回答
尤禮

事件失效了。
方案1:需要重新綁定點(diǎn)擊事件。
dom繪制后,a標(biāo)簽已經(jīng)不是之前被選擇的了,重新綁定即可解決。
方案2:使用document事件代理

$(function() {
    $(document).on('click', 'tbody a', function(){
        // some code...
    });
});
2018年5月14日 17:24
編輯回答
蝶戀花

無(wú)代碼,無(wú)真相啊
不過(guò),你可以監(jiān)看一下是否有什么報(bào)錯(cuò)信息

2017年2月16日 02:30