/*鎻愮ず淇℃伅璇█鍖?/ var dataMax = "鍒嗛〉杈撳叆妗嗙己灏慸ata-max灞炴€?; var windowTitle = "鎻愮ず淇℃伅"; var windowOK = "纭畾"; var tooLarge = "鎮ㄨ緭鍏ョ殑椤电爜杩囧ぇ"; var loadingMsg = "鏁版嵁璇锋眰涓紝璇风◢鍚庘€?; var loading = true;//鏄惁鏄剧ずlayer鍔犺浇涓晥鏋 /* 浣跨敤鎻忚堪 蹇呴』class tabList(閫夐」鍗″惊鐜綋)銆乨ivList(鍒楄〃瀹瑰櫒寰幆浣?銆乸ageList(鍒嗛〉瀹瑰櫒寰幆浣?銆乬otobtn(go鎸夐挳)銆乬ototext(璺宠浆杈撳叆妗? 蹇呴』灞炴€ data-max(gototext鍏冪礌涓? */ function setHtml(index, msg) { //闈炵壒娈婃儏鍐典笉闇€瑕佷慨鏀 $('.divList:eq(' + index + ')').html($(msg).find('div').parents('.divList').html()); $('.pageList:eq(' + index + ')').html($(msg).find('div').parents('.pageList').html()); imgratio(); //濡傛湁鍥炶皟浜嬩欢 灏嗕唬鐮佹斁浜庢澶勫嵆鍙 } //鍗曠嫭璋冪敤DEMO 涓€鑸敤浜庡垵濮嬬涓€椤靛姞杞 //ajaxPageHelp('AjaxPage.html', function (msg) { // $('div.divList').html($(msg).find('div').parents('.divList').html()); // $('div.pageList').html($(msg).find('div').parents('.pageList').html()); //}) $(document).on('click', '.pageList a', function() { var index = $('.pageList').index($(this).parents('.pageList')); var href = $(this).attr('href'); if (href != 'javascript:void(0);') { ajaxPageHelp(href, function(msg) { setHtml(index, msg) }) } return false }); $(document).on('keyup', '.gototext', function() { IsNumber(this, 1) }); var regNumber = /^\d+$/; function IsNumber(obj, obj2) { if (!regNumber.test($(obj).val())) { if ($(obj).val().length > 0) { $(obj).val(obj2) } } } $(document).on('keyup', '.gototext', function(e) { var curKey = e.which; if (curKey == 13) { var index = $('.gototext').index($(this)); if ($(this).val().length == 0) { $(this).val('1') } $('.gotobtn:eq(' + index + ')').click() } }); $(document).on('click', '.gotobtn', function() { var index = $('.gotobtn').index($(this)); console.log(index); var gototext = $('.gototext:eq(' + index + ')').val(); var gotomax = $('.gototext:eq(' + index + ')').attr('data-max'); var d = $('.divList:eq(' + index + ')'); var p = $('.pageList:eq(' + index + ')'); if (gotomax == undefined) { var thisIndex = layer.alert(dataMax, { time: 0, title: windowTitle, closeBtn: 0, btn: [windowOK], yes: function(index) { layer.close(thisIndex) } }); return false } if ($(this).val().length == 0) { $(this).val('1') } if (Number(gototext) > Number(gotomax)) { var thisIndex = layer.alert(tooLarge, { time: 0, title: windowTitle, closeBtn: 0, btn: [windowOK], yes: function(index) { layer.close(thisIndex) } }); return false } var hrefTitle = ''; var hrefSuffix = ''; var regHref = /(.+)_(\d{1,})\.(.+)/; p.find('a').map(function() { if (hrefTitle.length == 0 && regHref.test($(this).attr('href'))) { hrefTitle = regHref.exec($(this).attr('href'))[1]; hrefSuffix = regHref.exec($(this).attr('href'))[3] } }); if (hrefTitle.length > 0) { var href = ""; if (Number(gototext) == 1) { href = hrefTitle + "." + hrefSuffix } else { href = hrefTitle + "_" + gototext + "." + hrefSuffix } ajaxPageHelp(href, function(msg) { setHtml(index, msg) }) } }); function ajaxPageHelp(url, fn) { if (loading) { var thisIndex = layer.msg(loadingMsg, { time: 0, icon: 16 }) } $.ajax({ "type": "get", "url": "" + url + "", "datatype": "html", "success": function(msg) { if (loading) { layer.close(thisIndex) } if (fn) { fn(msg) } }, "error": function() { if (loading) { layer.close(thisIndex) } } }) }