The following code works fine if I don't use return false;
in imageload
function. But if use return false;
it's not working. I even tried break. It didn't help.
function fileshow(sel){
var file=sel.files[0];
var imagetype=file.type;
var match= ["image/jpeg","image/png","image/jpg"];
if(!((imagetype==match[0]) || (imagetype==match[1]) || (imagetype==match[2]))){
return false;
}
else{
var reader = new FileReader();
reader.onload = imageload;
reader.readAsDataURL(sel.files[0]);
}
}
function imageload(e){
$(".fileshow").each(function(){
if($(this).val()==''){
$(this).siblings(".inner_mainphoto").find("img").attr("src", e.target.result);
return false;
}
});
}
Update
I want to break out of the each function if $(this).val()
is empty.