0

I have an array like the following:

aVN = new Array();
aVN.push(new Array('CET', 'July', 'Birthday',    '20110704'));
aVN.push(new Array('CGT', 'July', 'Anniversary', '20110705'));

I also have multiple <li> elements in my html like this:

<li id="thismonth">
   <ul>
      <li id="20110701">1</li>
      <li id="20110702">2</li>
      <li id="20110703">3</li>
      <li id="20110704" onclick="displayevent();" class="holiday">4</li>
      <li id="20110705">5</li>
   </ul>

I want to check whether 20110704 from the array aVN is present in the IDs of the <li>s.

If the ID and the array value match, then I want to display "Birthday" (the text from the array) when I click on that particular <li>.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
user550884
  • 31
  • 2
  • 3
  • 8
  • 2
    Element IDs can't start with a number. They must begin with a letter. – damon Jul 20 '11 at 14:08
  • 2
    @damon in HTML5, this restriction is lifted. – Matt Ball Jul 20 '11 at 14:11
  • @Matt: That's great; doesn't mean we should start piling out code with strictly numeric IDs, though. Not just yet anyway. – Lightness Races in Orbit Jul 20 '11 at 14:23
  • @Matt, interesting.. hadn't notice that.. thanks for the heads up.. – Gabriele Petrioli Jul 20 '11 at 14:25
  • @Matt: I didn't know that, thanks! Apparently, you can even use unicode!

    – damon Jul 20 '11 at 15:21
  • @damon what makes you think you're _not_ using unicode with alphanumeric characters? – Matt Ball Jul 20 '11 at 15:24