Why does quoting matter with getElementById?

s_kumar

New Member
I have a dom object like this within an html page:\[code\]<textarea id="owctl7fzk">?foo</textarea>\[/code\]When I try to access it with \[code\]getElementById\[/code\] without quoting the id, it returns \[code\]null\[/code\].\[code\]window.document.getElementById(owctl7fzk)\[/code\]but when I put the id within single or double quotes, it selects the object:\[code\]window.document.getElementById('owctl7fzk')window.document.getElementById("owctl7fzk")\[/code\]Why does the quotation matter in this case? In general, when you can you omit and when can you not?
 
Back
Top