I'm trying to get my head around this method and I'm getting results
unexpected results. I'm trying to get the index number of the th's that
have the '.asc' class. Any ideas why the second one is returning -1 ?
Thank you! :)

<html>
<head>
        <script src="jquery.js" type="text/javascript"></script>
        <script>
        $(document).ready(function() {
                $("table.simple").each(function() {
                        var x = $('th',this).index($('.asc')[0]);
                        alert(x); 
                        //first returns 2, as expected
                        //second returns -1, should it be 0?
                });
        });
        </script>
</head>

<body>
<table class="simple">
        <thead>
                <tr>
                        <th>Column 1</th>
                        <th>Column 2</th>
                        <th class="asc">Column 3</th>
                </tr>
        </thead>
        <tbody>
                <tr>
                        <td>Data 1</td>
                        <td>Data 2</td>
                        <td>Data 3</td>
                </tr>   
        </tbody>
</table>
<table class="simple">
        <thead>
                <tr>
                        <th class="asc">Column 1</th>
                        <th>Column 2</th>
                        <th>Column 3</th>
                </tr>
        </thead>
        <tbody>
                <tr>
                        <td>Data 1</td>
                        <td>Data 2</td>
                        <td>Data 3</td>
                </tr>   
        </tbody>
</table>
</body>
</html>



 
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to