Reputation: 897
<span id='a'><img src='b.gif' /></span>
<script>
alert(document.getElementById('a').innerHTML);
</script>
The output is: <img src="b.gif" />
'b.gif' is being shown as "b.gif"
Viewing the source code in FireBug also shows double quotes. Why is this happening?
Upvotes: 2
Views: 391
Reputation: 19963
Double quotes are the standard for attributes, single quote are obviously acceptable though.
The innerHTML
is the processed set of tags, so the browsers will set the attributes with double quotes as standard
As has been pointed out, there is no "standard" when it comes to double or single quotes on attributes.
My guess would be that browsers use double quotes by default, and therefore when you request the innerHTML
, it will format them as such. If I am incorrect, I will remove this answer immediately
Upvotes: 2