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.
Yes, 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With