打破jQuery的所以我用這個函數()功能在IE
months = months.filter(function(e, p) { return months.indexOf(e) == p; });
和測試alert();
作品只有前。如果我把alert()放在這個函數的下面,它就不再工作了......
這隻發生在IE中,在Chrome中它很好。這打破了它下面的每個jquery。你可以看到現場的問題Here
而且,直接鏈接到js文件是Here
此功能有過濾重複months
從李德全data-mes
屬性在該網頁上...我有不知道爲什麼會這樣,也,我用這:
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
但是,aparently在這個問題沒有效果....
下面是這個問題的全部代碼:
// gets all `data-mes` into an array
var months = $('#gride li').map(function() { return $(this).data('mes'); }).get();
// remove repeated meses
months = months.filter(function(e, p) { return months.indexOf(e) == p; });
// sorts the months
var order = ['janeiro','fevereiro','março','abril','maio','junho','julho','agosto','setembro','outubro','novembro','dezembro'];
orderedMonths = months.sort(function(a,b){ return order.indexOf(a) - order.indexOf(b); });
// add them, ordered, to the <select> with id #selectMes
$.each(orderedMonths, function(_, v) {
$('#selectmes').append($('<li class="filter" data-filter="'+ v +'">').val(v).text(v));
});
非常感謝你,不幸的是,這段代碼沒有工作... – user1576978
我編輯了這個部分的全部js的問題,如果你可以看看 – user1576978
@ user1576978任何機會你有什麼錯誤得到些什麼?試試這個'months.filter(function(e,p,arr){return $ .inArray(e,arr)== p});' – PSL