var srcType = source.slice(source.lastIndexOf('.'));
//srcType = fileExtension
var imageFormats = ['.jpg','.png','.gif'],
videoFormats = ['.ogv','.png','.gif'];
// two lists, acceptable video/image types
var htmlSting = '';//initialize the htmlstring
if (srcType in imageFormats) //heres where my question is!!!
htmlString = '<img class="empty" id="it" src="'+source+'"> </img>';
else
htmlString = '<video class="empty" id="it" src="'+source+'" controls> </img>';
// these statements choose the proper media type.
좋아요, 그래서 heres 거래 : 나는 파일 형식에 따라 html을 선택해야하는 것을 코딩하고 있습니다. (imageFormats의 srcType)을 구현하는 방법은 무엇입니까? 이것은 작동하지 않습니다. for 루프가 필요합니까? 항상 HTML을 사용하거나 HTML에서 사용할 수 있지만 형식을 추가 할 때마다 철저히 구별됩니다. 이유는 for 루프가 좋지 않은 이유는 시간이 중요한 영역에서 소중한 시간을 사용하기 때문입니다.in 연산자를 사용하여 if 문 사용
고마워요! 방금 객체 배열로 만들었습니다. D –