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.

Just came across this and I can think of one pretty good reason javascript could see commented code. If you write a help system using javascript t ... Read more.

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from 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

Similar Entries

Stats

394 unique visits since August 2008

Syndicate

Advertisements