所以我有一个函数为每个'#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