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'/>"); }); 

http://jsfiddle.net/eczp4/

here jquery documentation replacewith() http://api.jquery.com/replacewith/


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -