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 9148993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:24:59+00:00 2026-06-17T11:24:59+00:00

I have a little snippet I want to make into a function. But I’m

  • 0

I have a little snippet I want to make into a function. But I’m new to javascript. Obviously there is something wrong with the way I pass variables or the way I call them…

So in nutshell, this works: http://jsfiddle.net/kkvbz/
But this doesn’t: http://jsfiddle.net/PrtD4/

Problem is I need it as a function, so I’ve to make 1 version work.

Full snippet:

function cutandMakeslides (containerid,liperslide) {
//This is for footer slider, it rewrites 1 ul into several uls that contain 4 li max.
    // get the container, useful for later too...
    var container = $(containerid);

    // get all available UL and LI elements...
    var li_elements = container.find("> UL > LI").clone();

    // remove the current content so that we can rebuild it for the slider...
    container.find("> UL").remove();

    // build the slider container...
    var slide_container = $("<div />");

    // tricky part: looping through the LI's and building each of the slides...
    // first create some helpful variables...
    var li_elements_per_slide = liperslide;
    var li_counter = 0;

    // create the first slide, with a UL to hold the LI's...
    var current_li_div = $("<div />");
    current_li_div.append($("<ul />"));

    // loop through the LI's...
    li_elements.each(function(index, element){

        li_counter++;
        var current_li = $(element).clone();
        current_li_div.find("> UL").append(current_li);

        if (li_counter % li_elements_per_slide == 0)
        {
            // we've hit 4 in this list, so add the slide and make
            // a new one, using same code as before...
            container.append(current_li_div);
            current_li_div = $("<div />");
            current_li_div.append($("<ul />"));
        }

    });

    // we might have an uneven number of LI's, so we need to check for this...
    if (li_counter % li_elements_per_slide != 0)
        container.append(current_li_div);
} // end function cutandMakeslides


    //activate function above
    $(function() { cutandMakeslides(".fproductslides",3); });

Problematic parts:

function cutandMakeslides (containerid,liperslide) {
var container = $(containerid);
var li_elements_per_slide = liperslide;
}
$(function() { cutandMakeslides(".fproductslides",3); });
  • 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-17T11:25:00+00:00Added an answer on June 17, 2026 at 11:25 am

    So after extensive testing and moving the code to a fiddle, the problem seems to have resolved itself during moving it to the fiddle, so we believe there was a minor spelling or syntax error…however using a code comparison tool I was unable to find anything…

    none of the problematic parts seemed to have an error:

    function cutandMakeslides (containerid,liperslide) {
    var container = $(containerid);
    var li_elements_per_slide = liperslide;
    }
    $(function() { cutandMakeslides(".fproductslides",3); });    
    

    Here’s a copy of the working fiddle

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

Sidebar

Related Questions

I have got this little snippet of code, I want to be able to
Say I have this little snippet: <p data-color=red>Hello world</p> An I want to set
I have little snippet for validatin' my form. I need help to position the
I have a little snippet that formats a date for a timestamp like this:
I have taken this little snippet straight out of some code I'm working on:
I have little bit longer question for you - but hope answer will be
There are many times when I need to test a little snippet of .NET
I have frequently run into the situation where I want to update many records
I've seen this somewhere before but I can't seem to find the little snippet.
I'm trying to make a little alert system to do something (IDK what I

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.