[Javascript] HTML Tag that can hold data for JavaScript?

Peter-Paul Koch pp.koch at gmail.com
Thu Feb 24 06:20:04 CST 2005


> What I'd like to do is create a tag that holds data that I can access in
> Javascript like this:
> <mycustomtag myProp1="myValue1" myProp2="myValue2"/>
> 
> but I don't know how to access the properties in js. I enumerated and
> there was no properties. Is there a tag that exists that I can use? I
> need it to be hidden because I only want to access it from js.

Can be done, though I advise you to use normal HTML tags: custom tags
are not accessible in all browsers.

See http://www.alistapart.com/discuss/scripttriggers/ for an article I
wrote recently about exactly this subject.

-- 
-------------------------------------------------------------------
ppk, freelance web developer

Recent article: JavaScript triggers, 
http://www.alistapart.com/articles/scripttriggers/

Bug Report: Report bugs yourself, or comment on previously 
reported ones.
http://www.quirksmode.org/bugreports/
------------------------------------------------------------------



More information about the Javascript mailing list