update the code part to actually write the letters to the screen:
 
JS CODE
----------------------
 $(document).ready( function() {
  // declare an array
  var capArr = [];
  var capStr = '';
  $('li').each(function(){
   var cap = $(this).html().substring(0,1);
   if (capStr.indexOf(cap) != 1) {
    capArr.push(cap.toUpperCase());
    capStr += cap;
   }
  });
  capStr = '| ';
 
  for (i=0;i < capArr.sort().length;i++) {
   capStr += capArr[i] + ' | ';
  }
 
  $('#letters').html(capStr);
 });
 
 
HTML
-------------------
 <div id="letters"></div>
 <li>jaime</li>
 <li>nacho</li>
 <li>noelle</li>
 <li>andy</li>
 <li>duncan</li>

  _____  

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Andy Matthews
Sent: Friday, May 11, 2007 4:18 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Suggestion - A | B | C | - Navigation container


This code gives you an arrary containing the first character of any string
inside a list item. You can then do whatever you want with it.
 
I only used the capStr var because I couldn't get indexOf working with the
capStr array. I'd also be interested in seeing if anyone has ideas to
improve the code.
 
JS CODE
---------------------------------------
 $(document).ready( function() {
  // declare an array
  capArr = [];
  capStr = '';
  $('li').each(function(){
   var cap = $(this).html().substring(0,1);
   if (capStr.indexOf(cap) != 1) {
    capArr.push(cap.toUpperCase());
    capStr += cap;
   }
  });
  alert(capArr.sort());
  delete capStr;
 });
 
LIST ITEMS
---------------------------------------
 <li>jaime</li>
 <li>nacho</li>
 <li>noelle</li>
 <li>andy</li>
 <li>duncan</li>

 
 

  _____  

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Mario Moura
Sent: Friday, May 11, 2007 3:21 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Suggestion - A | B | C | - Navigation container


Hi Folks

This email is a suggest to a new plugin.

Is it possible from a list <li> create a A/B/C Navigation container?

A | B | C | ...

Accessible Travel
Assisted Living
... 

If is possible please let me know, If not feel free to use it.

Regards

Mario

Reply via email to