By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

simple javasvript id question

100+
P: 178
Hi,

when giving an object an id in javascript can I use characters like % $ & ?
Nov 25 '08 #1
Share this Question
Share on Google+
2 Replies


acoder
Expert Mod 15k+
P: 16,027
You should avoid special characters. See Basic HTML data types.

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Nov 25 '08 #2

P: 35
this one works, but yep you should avoid those special chars
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <style>
  4. #{font-size: 308px;}
  5. </style>
  6. </head>
  7. <body>
  8. <div id=""></div>
  9.  <script>
  10.  ar='cris'
  11. document.getElementById('').innerHTML=ar
  12. </script>
  13. </body>
  14. </html>
  15.  
Nov 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.