Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript run a particular css class on page load

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #151939
    jaswinder
    Participant

    hi friends.

    i want to run a particular class from stylesheet on pageload… right now that class is called by clicking a button ,,

    how could i do it ??

    #151943
    lrelia
    Participant

    JQuery can help.

    $('button').click(function() {
     $('html').addClass('whatYouWant');
    });
    
    #151949
    Paulie_D
    Member

    Why wouldn’t the class in a stylesheet just apply when the stylesheet loads or am I missing something?

    #151960
    nkrisc
    Participant

    If you want the class applied to an element on load of the page why not just put the class inline in the HTML? Why do you need js to do this?

    <someElement class="someclass"></someElement>

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.