function run(){ if($('.bankort').length == 0){ var refreshIntervalId = setInterval(function(){ if($('input[name="test"][value="bank_transfer"]').length > 0){ clearInterval(refreshIntervalId); get_data(); } }, 300); } } $(document).on('change','#country',function(){ $('.bankort').remove(); run(); }); $(document).on('click','#na',function(){ $('.bankort').remove(); console.log('na') run(); }); run(); function get_data(){ $.getJSON('bank.php?a=1',function(data){ var reId = setInterval(function(){ console.log('reid:'+reId) if($('input[value="bank_transfer"]').parent().parent().css('display')=='block'){ clearInterval(reId); bank(data); } }, 300); }); } function bank(data){ $('input[value="bank_transfer"]').parent().parent().hide() var l=2; if($('#top-language span').text().indexOf('English') != -1 || $('#language_form a:eq(0)').text().indexOf('English') != -1 || $('#language button img').attr('alt') == 'English'){ l=1; } var v=data['bank_transfer_bank'+l].split('\n\n'); $('.bankort').remove(); var bankt=''; for(var i in v){ var vv=''; if(v[i].split('\n').length == 2){ vv=v[i].split('\n')[0]; } if(v[i].split('\n').length == 3){ vv=v[i].split('\n')[1]; } if(vv != undefined && vv !='' && vv.indexOf('Please send us your payment') == -1){ bankt=bankt+'
'; } } $('input[value="bank_transfer"]').parent().parent().after(bankt); $(document).on('click','input[name="test"]',function(){ $('input[name=vv]').prop('checked', false); }); $(document).on('click','input[name="vv"]',function(){ $('input[name="test"][value="bank_transfer"]').prop('checked', true); }); $(document).on('click','#sconfirm',function(){ if($('input[name="vv"]:checked').length > 0){ $('#comment').val($('#comment').val().replace(/付款方式:(.*)\n/,'')); $('#comment').val("付款方式:"+$('input[name="vv"]:checked').parent().text()+"\n"+$('#comment').val()) } }) }