JavaScript can access hidden HTML Jul27 '06

Something interesting, but probably absolutely useless, but I’d thought I’d share, anyway...

<!--

<p id="para"></p>

-->

See how this is hidden from the browser, with HTML comment tags?

However, JavaScript can still access this paragraph, even though it’s hidden from view:

var para = document.getElementById("para");

I don’t know what purpose this serves, but I noticed it, so I’d thought I’d share.

Carry on.

Categories: HTML , JavaScript

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Actually in the product I work on, we use hidden form fields all over the place to pass data between UI stuff when it is not worth sending back to ... Read more.

Yes, but hidden form fields are different - Matt’s talking about commented out HTML! I find that very strange that Javascript can "see" that ... Read more.

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from a suburb of Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

Popular Pages

  1. Fast rounded corners in Photoshop (7875 recent visits)
  2. PHP – passing variables across pages (2860 recent visits)
  3. JavaScript set selected on load (2345 recent visits)
  4. Removing all child nodes from an element (1704 recent visits)
  5. iPod songs out of order? (1412 recent visits)
  6. Firefox 3 smart address bar: wildcard search (1300 recent visits)
  7. Britney - Everytime piano tab (1180 recent visits)
  8. MySQL LEFT JOIN syntax (971 recent visits)
  9. Breathe Me - Sia (824 recent visits)
  10. Tumblr: how blogging should be (727 recent visits)

Similar Entries

Stats

125 unique visits since August 2008

Syndicate

Advertisements