Canna
Canna

Reputation: 3794

Put a quote in a HTML attribute

example,

<span class="hotspot" 
    onmouseover="tooltip.show('<table id=\"test\"><tr><th>123</th></tr><tr><th>123</th></tr></table>');" 
    onmouseout="tooltip.hide();">porttitor orci</span> 

in here, i'm trying to add id attribute in table tag, but i already used "" and '', so something is messed up and not working.

Any good solution?

Upvotes: 0

Views: 104

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201518

In an attribute value that is delimited by Ascii quotation marks ("), you can present the Ascii quotation mark itself using the reference &quot;.

However, there is usually a better way. In the given case, you can simply omit the quotation marks, since id=test works just fine (unless you are using XHTML served with an XML content type, and most probably you aren’t).

Upvotes: 1

Paul Draper
Paul Draper

Reputation: 83205

<span class="hotspot" 
    onmouseover="tooltip.show('<table id=&quot;test&quot;><tr><th>123</th></tr><tr><th>123</th></tr></table>');" 
    onmouseout="tooltip.hide();">porttitor orci</span> 

JSFiddle

Upvotes: 4

Related Questions