-1

How do I change this html:

<div data-label="FileInput">
    <img src="the source"></img>
    <div>Stuff</div>
    ... etc ...
</div>

To a file input using jQuery? I cannot change the structure of the html, and I need to target the container div (data-label="FileInput")..

I'm still a beginner with js / jQuery, so if you could be explicit with how to do this I would greatly appreciate it! Thanks for your ideas!

3
  • div[data-label='FileInput'] Commented May 28, 2014 at 17:08
  • What do you mean change the html "To a file input"? Let the user input the file path/select a file on their system? Commented May 28, 2014 at 17:10
  • @Andrew yes exactly. Thanks for any ideas. Added to the question to make it more clear.. Commented May 28, 2014 at 17:19

1 Answer 1

2

Just do:

$("div[data-label=FileInput]").replaceWith("<input type='file' />");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.