Losing img tag closure using jQuery.html () method

I use the jQuery method .html()to dynamically add images to a div on my web page when a user clicks on the event to which the image belongs.

I have confirmed that the image tag is correctly formatted when returning to the server, but after installation with the help, the .html()end part of the tag is lost.

For example, initially

<img src="poop.txt"></img>

It turns out like

<img src="poop.txt">

on the actual web page. What is the reason for this? .html()works great with the set of runs that I paste in a similar way to another page on the site, but when it comes to image tags, it fails.

+5
source share
3 answers

( ) , JavaScript , , jQuery, HTML. img ( , ), -.

:

+2
0

JQuery generates valid HTML. </img>does not exist in the html standard.

0
source

All Articles