With the following Jquery - I am trying to default the value of a select to Publication Date:

<script>
$('[name=form-control] option').filter(function() { 
    return ($(this).text() == 'Publication Date');
}).prop('selected', true); 
</script>

Here is the select code - I'm trying to default to another value:

<select class="form-control" data-bind="options: filterParams.sort , optionsText: 'name', optionsValue: 'value', value:filterParams.selectedSort , event:{ change: $root.bindPrograms}"><option value="author">Author </option><option value="availableDate">Publication Date</option><option value="name">Title </option><option value="viewCount">Viewed </option></select>

What is the best way to accomplish because the script won't set that select to the value I want.

Ideally - and also I - don't know the best way to have the sort field whose span class by default is as such to be descendingSort:

<span class="toggleButton modalButtons ascendingSort" data-bind="click: $root.sort"></span>

When I click the sort it displays the code as such:
<span class="toggleButton modalButtons ascendingSort descendingSort" data-bind="click: $root.sort"></span>

<option value="availableDate" SELECTED>Publication Date</option>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.