Cameron Bass Cameron Bass - 1 year ago 103
jQuery Question

JQuery page load: Active class

I have some JQuery that will set a class to active onclick. but when I load the page nothing is "Active" not until I click one of the list items. Is there a way that one can be select upon the page load?

Current JQuery:

$(".setup-nav").on( "click", "li", function() {

Answer Source

Just add active to your the HTML item.

<ul class="setup-nav">
    <li class="active">This is your fist active item</li>
    <li>Second Item</li>

And, to prevent keeping the last change by soft reloading the page which could be happened by some browsers, just use this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download