title: Javascript/jquery - Add a class to list at variable position
body: <p>I have a variable which contains an item number ... like this:</p>
  
  <pre><code>myvariable = '3'; //Note: This is currently a string so it might need converting?
  </code></pre>
  
  <p>Then I have the code which populates the listview:</p>
  
  <pre><code>$('#listview').live("pageinit", function(){
  $.getJSON("myjson.json", function(data){
      $.each(data.unis, function(index, value){
  
  
          $('&lt;li&gt;&lt;a class="listitem" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;').insertAfter('#' + value.sortLetter);
  
          $('#' + value.sortLetter).show();
  
      });
  
      $("#listview").listview("refresh");
  
  
  });
  </code></pre>
  
  <p>All the above works fine.</p>
  
  <p>Now, what I need to do it to insert a class into the item which is at the position myvariable value.</p>
  
  <p>So, if myvariable is <code>3</code> then the listview will look like this:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;li&gt;&lt;a class="listitem" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a class="listitem" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a class="listitem AddedClassHere" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>if myvariable was to be <code>1</code> then:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;li&gt;&lt;a class="listitem AddedClassHere" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a class="listitem" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a class="listitem" href="#"&gt;' + value.name + '&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>and so on...</p>
  
  <p>How could I do this?</p>