Why does this not add “accept” attribute to input field?
var input = $("<input>").attr(“type”,“file”).attr(“name”,“images”).attr(“class”,“uploader”).attr(“id”,“img” + nextInt).attr(“accept”, “images/jpg, images/jpeg”);
Why does this not add “accept” attribute to input field?
var input = $("<input>").attr(“type”,“file”).attr(“name”,“images”).attr(“class”,“uploader”).attr(“id”,“img” + nextInt).attr(“accept”, “images/jpg, images/jpeg”);
Is nextInt
defined anywhere?
e.g.
var nextInt = 3;
var input = $("input").attr("type","file").attr("name","images").attr("class","uploader").attr("id","img" + nextInt).attr("accept", "images/jpg, images/jpeg");
Yes it is a defined value, works perfectly apart from the attr(accept) bit
Seems to work for me with the correct quote tags in place.
Devtools shows this:
<input type="file" name="images" class="uploader" id="img3" accept="images/jpg, images/jpeg">
Use:
.attr("accept", ".jpg,.jpeg")
or to accept any image file use:
.attr("accept", "image/*")
Yep that worked!! Cheers
Well spotted
I only checked that the accept attribute was added and not that the value was correct
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.