Timeline for JavaScript function to get DOM elements by any attribute
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 23, 2017 at 12:40 | history | edited | CommunityBot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
Jul 30, 2012 at 18:07 | comment | added | delete me |
@JohnH element.attributes is never an array; it's an array-like object. But even when there are 0 attributes, it is set to an object with a length of 0. So, the first comparison of the loop would return false without error.
|
|
Jul 27, 2012 at 16:40 | comment | added | John H | I didn't realize that the check in your first note was unnecessary, I thought the interpreter might throw an error if it tried to loop something that wasn't an array. Your second note helped make my code more readable. Thank palacint! | |
Jul 27, 2012 at 1:26 | history | answered | palacsint | CC BY-SA 3.0 |