2

I've noticed that Google Chrome wraps inner text of elements in double quotes, however, the Html() Jquery function returns a string without quotes . Why is that ?

And here are some experiments :

Html Code :

<p id="simple-text">This is a simple paragraph .</p>

<p id="lorem-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p id="span-text">This is a simple <span>span element</span> paragraph .</p>

Result in Chrome ( Elements ):

Elements

Note: There are no double quotes in the simple text (#simple-text)

Result in Chrome using Jquery ( Console ):

Jquery

Note: There are no double quotes in the span text (#span-text)

Update (Editing Html) :

enter image description here

enter image description here

Could I say that there are three elements : string, span, and a string ?

3
  • 2
    In that last picture, all of the inner HTML is undefined because innerHtml isn't actually a property, it should be innerHTML
    – Sidney
    Commented Mar 20, 2018 at 17:48
  • @Sidney : Thanks man
    – CryptoBird
    Commented Mar 20, 2018 at 17:50
  • The Chrome console pretty much does whatever the developers want it to do. It's trying to be helpful but there are lots of similar questions about how the console presents information.
    – Pointy
    Commented Mar 20, 2018 at 17:52

1 Answer 1

9

The quotes aren't actually a part of the DOM, it's just a UX feature in DevTools to indicate it's a string you're looking at.

enter image description here

If you right click the element and select Edit HTML, you'll see the raw HTML.

enter image description here

3
  • Thank you so much, (these quotes made me crazy) that makes sense now .
    – CryptoBird
    Commented Mar 20, 2018 at 17:54
  • So in the span-text , there are three elements : string, span, and a string? right ?
    – CryptoBird
    Commented Mar 20, 2018 at 17:58
  • "TextNode" would be better than "string" here.
    – Kaiido
    Commented Jan 20, 2020 at 7:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.