Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:18:32+00:00 2026-05-31T00:18:32+00:00

I have the following. I am trying to trigger the function based on the

  • 0

I have the following. I am trying to trigger the function based on the css class changing but it’s not working.

<script type="text/javascript">

jQuery(document).ready(function(){

jQuery("#slider-banner").bind("cssClassChanged",function(){
    console.log("I'm Here!");
    if(jQuery("#slider-banner").hasClass('living-nutrients'))
    {
        jQuery("#home-middle-first").css("background-image","url([image path])");
    }
    else if(jQuery("#slider-banner").hasClass('right-partner'))
    {
        jQuery("#home-middle-second").css("background-image","url([image path])");
    }
    else if(jQuery("#slider-banner").hasClass('with-you'))
    {
        jQuery("#home-middle-third").css("background-image","url([image path])");
    }
});

    jQuery("#slider-banner").trigger('cssClassChanged');

The colsole displays my console.log message on page load, but not when the class changes again after page load. Anyone see what I’m doing wrong?

UPDATE:

So I’ve learned that “cssClassChanged” is not legit… I was attempting to adapt an answer I found somewhere else… I do realize that if jQuery were a weapon, I’d be dangerous! (knowing that is half the battle, right?)

My attempt to adapt gdoron’s answer linked to below:

<script type="text/javascript">

jQuery(document).ready(function() 
{
    function checkForChanges()
    {
        if(jQuery("#slider-banner").hasClass('living-nutrients'))
        {
            jQuery("#home-middle-first").css("background-image","url([image path])");
        }
        else if(jQuery("#slider-banner").hasClass('right-partner'))
        {
            jQuery("#home-middle-second").css("background-image","url([image path])");
        }
        else if(jQuery("#slider-banner").hasClass('with-you'))
        {
            jQuery("#home-middle-third").css("background-image","url([image path])");
        }

        else
            setTimeout(checkForChanges, 500);
    }
});
</script>

I’m still missing something, though. It only works for the first class on page load.

Someone asked how I’m changing the classes. I’m using a slider and on each slide is a div with the ID “slider-banner” and the class varies depending on which of the three ID’d areas below it that I am trying to switch the background image for.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:18:33+00:00Added an answer on May 31, 2026 at 12:18 am

    There is no such event cssClassChanged I think that explains all…

    10 hours ago I answered how you can detect class change, read my answer there


    Update:

    function checkForChanges()
    {
        var sliderBanner = jQuery("#slider-banner");
        if(sliderBanner.hasClass('living-nutrients'))
        {
            jQuery("#home-middle-first").css("background-image","url([image path])");
        }
        else if(sliderBanner.hasClass('right-partner'))
        {
            jQuery("#home-middle-second").css("background-image","url([image path])");
        }
        else if(sliderBanner.hasClass('with-you'))
        {
            jQuery("#home-middle-third").css("background-image","url([image path])");
        }    
    
        setTimeout(checkForChanges, 500);
    }
    
    jQuery(checkForChanges);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following members defined in a class that I'm trying to deserialise:
I'm trying to use opengl in C#. I have following code which fails with
I have the following interface which I'm trying to make COM-visible. When I try
I have the following Transact-Sql that I am trying to convert to LINQ ...
I have the following code that I am trying to extract the systems proxy
I have the following code that i am trying to change from a regular
I have the following SQL statement where i'm trying to update multiple rows matching
I have the following problems: First: I am trying to do a 32-spaces bitwise
I have the following data set that I am trying to plot with ggplot2,
I have the following code sample that im trying to wrap my head around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.