javascript - Changing type of an input -
i want change type of input on click of button doesn't work. tried this:
$('.addphoto').click(function(){ $(this).siblings('.auto_image').prop("type", "file"); });
it doesn't @ all. searched on google , came across this: change type of input field jquery
it says possible straight dom, how select class of sibling dom?
you can replace element don't think can change type attribute see example.
$('.addphoto').on("click",function(){ $(this).off("click").replacewith("<input type='file' class='addphoto'/>"); });
or
$('.addphoto').one("click",function(){ $(this).replacewith("<input type='file' class='addphoto'/>"); });
here jquery documentation replacewith()
http://api.jquery.com/replacewith/
Comments
Post a Comment