admin管理员组文章数量:1334923
I'm doing some attribute parsing as a string, so I need to know how spaces are used in HTML/XHTML element attributes:
<div id='myid' width='150px' />
Is this also correct?
<div id = 'myid' width = '150px' />
If anyone knows other ways of iterating through attributes and their values using JavaScript, I'd be interested to know.
I'm doing some attribute parsing as a string, so I need to know how spaces are used in HTML/XHTML element attributes:
<div id='myid' width='150px' />
Is this also correct?
<div id = 'myid' width = '150px' />
If anyone knows other ways of iterating through attributes and their values using JavaScript, I'd be interested to know.
Share Improve this question edited Feb 1, 2015 at 16:43 Deduplicator 45.7k7 gold badges72 silver badges123 bronze badges asked May 6, 2009 at 6:18 Robin RodricksRobin Rodricks 114k147 gold badges414 silver badges617 bronze badges 2- You might want to specify what language you're trying to do the parsing in - if in C, C#, JavaScript. If JavaScript, are you perhaps trying to your own HTML document from within a browser, or offline? – Shalom Craimer Commented May 6, 2009 at 6:27
- Note that the width attribute is (a) deprecated and (b) takes either an integer or percentage - don't specify px in HTML (but always specify units in CSS). The validator won't pick this up, because the DTD doesn't express this rule (and I don't think DTDs are capable of doing that either) – Quentin Commented May 6, 2009 at 8:35
2 Answers
Reset to default 8Yes, both are correct. Rather than string parsing, you'll want to use the DOM. Check out jquery.
The spaces are allowed. If you are parsing attributes why don't you let the browser parse? If you are using innerHTML than you get elements that have an attribute list
本文标签: javascript(Simple) Are HTML attributes allowed to have spaces between assignmentsStack Overflow
版权声明:本文标题:javascript - (Simple) Are HTML attributes allowed to have spaces between assignments - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742378801a2463699.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论