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

  • SEARCH
  • Home
  • 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 8472505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:05:40+00:00 2026-06-10T17:05:40+00:00

Ive created a loop to assign the class ‘last’ to every fifth element but

  • 0

Ive created a loop to assign the class ‘last’ to every fifth element but for some reason .className doesn’t seem to work. I originally used .class but ie7 and ie8 error out at this. Can anyone advise how I can resolve this?

JS Snippet

success: function(response) {
                    var source = $("#calendar-template").html(),
                            template = Handlebars.compile(source),
                            gameHTML = '';

                    for (var i = 0, gameLength = response.data.games.length; i < gameLength; i++){
                        var thisGame = response.data.games[i];
                        console.log(thisGame);
                        thisGame.className = ((i+1) % 5 == 0) ? 'last' : '';

                        gameHTML += template(thisGame);
                    }

                    instance.selectors.dateWrapper.append(gameHTML);

                    deferredObject.resolve();

                    instance.displayGames();
                },

Response

data: Object
games: Array[18]
0: Object
1: Object
2: Object
3: Object
...

Cheers

  • 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-06-10T17:05:42+00:00Added an answer on June 10, 2026 at 5:05 pm

    I could understand that you are using the handlebars library.

    response.data.games is a object that contains the context for existent HTML content. The call template(thisGame) will substitute some parts of the #calendar-template element. Probably you have a {{class}} as handlebar expression somewhere. So, YOU SHOULD use thisGame.class and not thisGame.className.

    Remember that you are not messing with a DOM element but with a handlebars context object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a method that generates a new class and adds some methods into
So say I've got a series of images created with a php loop ->
Ive created a function which returns all the obserables items in my html page.
ive created a lightbox where I have centered the div horizontally and vertically with
Im using virtualenv on Fedora 16 and Ive just created a new virtualenv so
Is it possible to loop in a wordpress plugin? I've created this plugin that
I've created a Jquery slideshow and it is working without problem, but this thing
I have created an array object with some dummy properties, I have have also
I got a loop {Loop-1} , where I start Threads. The class which contains
I've created a cursor to select the actual data, and loop through it outputting

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.