【发布时间】:2017-06-30 01:27:55
【问题描述】:
我想检查它的有效图像与否。 我的代码有效图像如下,它的工作很完美,但是当它的图像数组时它不起作用?
$("#file").change(function() {
var val = $(this).val();
switch(val.substring(val.lastIndexOf('.') + 1).toLowerCase()){
case 'gif': case 'jpg': case 'png':
//alert("an image");
break;
default:
$(this).val('');
// error message here
alert("Please Select Valid Image");
break;
}
});
它对一个图像的完美工作意味着它在 id 上的工作,但现在我想使用图像数组,那么我该怎么办?有没有可能?
<input id="file" type="file" name="images[]">Enter 8 Images For Batter Product View
<input type="button" id="addmore" value="Add More Image">
在添加更多图像时,它给了我新图像,所以我获取了一个数组,所以我想在数组中检查这个更改函数是否为有效图像? 有可能吗?
谢谢
【问题讨论】:
标签: javascript html arrays arraylist