title: javascript - use html ID tag or add property to element?
body: <p>I am using Prototype.js, but this probably applies to jQuery as well: I have a html list with a bunch of rows where each row is related to an object in javascript which is contained in an array. So:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li id="0"&gt;blah&lt;/li&gt;
      &lt;li id="1"&gt;blahblah&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I am currently using the id tag to find the javascript object refers to. So when the user clickes on the row, the event code will look something like:</p>
  
  <pre><code>var clickedItem = event.findElement('li');
  if (clickedItem) {
      var itemID = clickedItem.identify();
      var foundBlah = blahList[itemID];
  </code></pre>
  
  <p>Is using the ID tags a bad idea and should I instead be adding a property to each row when it is created, such as:</p>
  
  <pre><code>   var blah = new Blah('blah');
     $(list).insert(&lt;li&gt;blah&lt;/li&gt;).blah = blah;
  </code></pre>
  
  <p>and then just retrieving that value in the event handler?</p>