Cameron Bass Cameron Bass - 2 months ago 6x
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() {


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: