所以我有一個函數爲每個'#tree ol li'啓動一個函數樹是從php腳本生成的文件和目錄的列表。 my認爲是否'#tree ol li a'錨元素的值以特定的擴展名結束並隱藏它。所以我試圖讓這個腳本..但它不工作.. 誰能幫我找到我在哪裏錯了當場..隱藏鏈接,如果它匹配一個數組的值
function checkstuff(){
i = 0;
$("#tree ol li").each(function(){
i++;
console.log(i);
var temp_val = $(this).children("a").attr("href");
var temp_val2 = temp_val.substr(temp_val.length - 4);
console.log(temp_val2);
var extArr = [".mp3",".wav",".m4a"];
if(temp_val2 == extArr[i]){
console.log(extAttr[i] + "WELL this should have worked..");
$(this).hide();
};
});
我知道我的循環有點搞砸了,但我故意這樣做。 – 2015-03-13 14:08:12
你能指定它不工作多遠嗎? – Burki 2015-03-13 14:09:52
一切似乎很好,直到console.log(temp_val2);因爲它正在觸發正確的值。 – 2015-03-13 14:11:04