$(".down-list1 .down-left a").each(function (k, v) { var files = $(v).attr("href"); //console.log(files); var point = files.lastIndexOf("."); var type = files.substr(point); if (type == ".ppt" || type == ".pptx" || type == ".pdf") { $(v).find("img").attr("src", "/_upload/tpl/0f/c8/4040/template4040/images/pdf.png") } })