Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    May 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting 2 classnames using jQuery

    Hi!

    I'm using a plugin that will automatically add on a classname whenever that page is active

    For instance,

    <div class="page1 active"></div>
    <div class="page2"></div>
    <div class="page3"></div>

    If the user goes to page2, it will be

    <div class="page1"></div>
    <div class="page2 active"></div>
    <div class="page3"></div>

    How do I use jQuery to detect and write something that
    if .page2 and .active {
    change background colour to red
    } else if (.page3 and .active) {
    change background colour to blue
    }

    Thanks you for reading and assistance!

  2. #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    9,864
    Thanks
    6
    Thanked 1,164 Times in 1,135 Posts
    You don’t do that with JavaScript at all. That’s what CSS is there for:

    Code:
    .page2.active {background-color: red;}
    .page3.active {background-color: blue;}


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •