1
I would like to insert a tag using append but whenever I try, it tries to insert an image in the div that I want to insert only the text, there is way to get?
<input type="file" multiple id="file-input" />
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<div id="id">
</div>
<script>
$("#file-input").change(function(){
$("#id").empty();
var names = [];
for (var i = 0; i < $(this).get(0).files.length; ++i) {
var thisfile = $(this).get(0).files[i].name;
$("#id").append("<img src='images/images/eventos/"+thisfile+"' /><br/>");
}
})
</script>
What do you mean "tag"? It’s not an image you want?
– Sergio
@Sergio I want to write the tag code in order to appear for example, <img src='images/images/events/1.jpg' />
– I_like_trains
I still don’t understand what you mean by "tag code"... You want to insert HTML without being interpreted, is that it? for the HTML view of the user?
– Sergio
@Sergio Exactly, is there a way to achieve this? I’ve used
.html()
but it didn’t work.– I_like_trains
Okay, then you should use
.text()
instead of.html()
. Test it and tell me if that’s what you wanted.– Sergio
@Sergio Tenta but only shows me the last selected image
– I_like_trains
Exactly, I’ll give you a more complete answer I just wanted to make sure that the
.text
is what you were looking for.– Sergio