Solved

Split table first and rest

Posted on 2013-12-05
1
199 Views
Last Modified: 2013-12-20
Im trying to split a table into first and rest rows, however my code doesnt seem to pull any rows:-
        function modTable($tableID) {
	        var $firstRow = $('#' + $tableID.id + ' tr:first');
	        var $restRows = $('#' + $tableID.id + ' tr').not(':first');
		}
        modTable($('#myTableID'));

Open in new window


Any ideas what Im doing wrong?

Thank you in advance
0
Comment
Question by:tonelm54
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39699467
Use :
        function modTable($table) {
	        var $firstRow = $('#' + $table.attr("id") + ' tr:first');
	        var $restRows = $('#' + $table.attr("id") + ' tr').not(':first');
		}
        modTable($('#myTableID'));

Open in new window


Or better :
        function modTable($table) {
	        var $firstRow = $('tr:first', $table);
	        var $restRows = $('tr:gt(0)', $table);
		}
        modTable($('#myTableID'));

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

by Julian Matz As of jQuery (http://jquery.com/) 1.4 the .live() method (http://api.jquery.com/live/) supports custom events as well as some standard JavaScript events that it previously didn't support. Among these is the submit event. Unlike …
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now