From the course: Design the Web: Creating a Sortable Table

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Setting a default sort on page load

Setting a default sort on page load

- [Voiceover] So now after writing one line of code, we have a sortable table using this plugin. So now what we're going to do is have the table automatically sort based on one of these individual table headings when the page loads. Now if we go back to our HTML file, we'll see that the HTML is in a specific order. Styling form elements here is at the top, with its date, and then CSS controlled SBG. So when the browser loads this page, this is the order that all the HTML gets loaded into the browser's RAM. So what we're gonna do back in the JavaScript file is change this when the page loads. So inside of the parenthesis for table sort order, we can add a couple of additional options. So the first thing we'll need to do is add a beginning and ending curly bracket inside of the parenthesis. This way we can add additional options inside of the table sorter function. And now let's split that open and inside here, let's add our first parameter, or our first property, which is called sort…

Contents