JQuery outerHTML close tag

I use jQuery to get the external html: $('.page')[0].outerHTMLand it works, but I have img tags that should be closed as follows: <img src="smth" />but outerHTML delete /. How to solve this problem?

UPD: Well, I still haven't found a solution. How to get external html without changes?

+4
source share
1 answer

It's not a problem. But the browser highlights the closing tag. Even if you use <img src="path.jpg">it manually , it displays correctly on the page. Although the practice of coding is to use closing tags for such elements.

- , <img src="path.jpg" />, <img src="path.jpg">, .

, .

+4

Source: https://habr.com/ru/post/1627108/


All Articles