You're missing a # in your selector for #myTable.
Even with the #, couldn't get your code to run... but the following
seems to work:

$( document ).ready( function() {
        var staffOrder = "";
        
        $( '#myTable tr' ).each( function( i,o ) {
                if ( staffOrder.length ) {
                        staffOrder += "," + $( this ).attr( 'class' );
                } else {
                        staffOrder = $( this ).attr( 'class' );
                }
        });
        
        alert('staffOrder = ' + staffOrder);
});

On Sat, Dec 11, 2010 at 8:36 PM, Rick Faircloth
<r...@whitestonemedia.com> wrote:
>
> Hope some of you jQuery and CF users can answer what
> seems to me should be an easy question, but I can't
> figure out how to write this jQuery to product a list
> of values.  (I'll use AJAX and JSON to send the value list
> to a cffunction for processing).
>
> Given this HTML:
>
>        <table id="myTable">
>
>                <tr class="1">
>                        <td>1</td>
>                </tr>
>
>                <tr class="2">
>                        <td>2</td>
>                </tr>
>
>                <tr class="3">
>                        <td>3</td>
>                </tr>
>
>                <tr class="4">
>                        <td>4</td>
>                </tr>
>
>                <tr class="5">
>                        <td>5</td>
>                </tr>
>
>        </table>
>
> How can I modify this jQuery to produce
> a list of the classes of the tr's above?
>
> (Output I'm looking for is "1,2,3,4,5" .)
>
> I get "staffOrder = " in the alert.  It's as if
> the "each" function below isn't working at all.
>
> Suggestions?
>
> Thanks!
>
> Rick
>
>
>        $(document).ready(function() {
>
>                var staffOrder = '';
>
>                $('myTable tr').each(function(i,o) {
>
>                        if      (       staffOrder.length
> )
>                                {       staffOrder += ',' + o.class;
> }
>                        else    {       staffOrder = o.class
> }
>
>                });
>
>                alert('staffOrder = ' + staffOrder);
>
>        });
>
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340013
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to