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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:57:37+00:00 2026-06-06T13:57:37+00:00

I have the following script: (function($) { $.fn.easyPaginate = function(options){ var defaults = {

  • 0

I have the following script:

(function($) {

    $.fn.easyPaginate = function(options){

        var defaults = {                
            step: 4,
            delay: 100,
            numeric: true,
            nextprev: true,
            controls: 'pagination',
            current: 'current' 
        }; 

        var options = $.extend(defaults, options); 
        var step = options.step;
        var lower, upper;
        var children = $(this).children();
        var count = children.length;
        var obj, next, prev;        
        var page = 1;
        var timeout;
        var clicked = false;

        function show(){
            clearTimeout(timeout);
            lower = ((page-1) * step);
            upper = lower+step;
            $(children).each(function(i){
                var child = $(this);
                child.hide();
                if(i>=lower && i<upper){ setTimeout(function(){ child.fadeIn('fast') }, ( i-( Math.floor(i/step) * step) )*options.delay ); }

                if(options.nextprev){
                    if(upper >= count) { next.addClass('stop'); } else { next.removeClass('stop'); };
                    if(lower >= 1) { prev.removeClass('stop'); } else { prev.addClass('stop'); };
                };
            });    
            $('li','#'+ options.controls).removeClass(options.current);
            $('li[data-index="'+page+'"]','#'+ options.controls).addClass(options.current);

            if(options.auto){
                if(options.clickstop && clicked){}else{ timeout = setTimeout(auto,options.pause); };
            };
        };

        function auto(){
            if(upper <= count){ page++; show(); }       
            else { page--; show(); }          
        };

        this.each(function(){ 

            obj = this;

            if(count>step){

                var pages = Math.floor(count/step);
                if((count/step) > pages) pages++;
                var ol = $('<ol id="'+ options.controls +'" class="pagin"></ol>').insertAfter(obj);

      if(options.nextprev){
            prev = $('<li class="prev">prev</li>')
                .appendTo(ol)
                .bind('click', function() {

                    //check to see if there are any more pages in the negative direction
                    if (page > 1) {
                        clicked = true;
                        page--;
                        show();
                    }
                });
        }

                if(options.numeric){
                    for(var i=1;i<=pages;i++){
                    $('<li data-index="'+ i +'">'+ i +'</li>')
                        .appendTo(ol)
                        .click(function(){    
                            clicked = true;
                            page = $(this).attr('data-index');
                            show();
                        });                    
                    };                
                };

        if(options.nextprev){
            next = $('<li class="next">next</li>')
                .appendTo(ol)
                .bind('click', function() {

                    //check to see if there are any pages in the positive direction
                    if (page < (count / 4)) {
                        clicked = true;         
                        page++;
                        show();
                    }
                });
        }

                show();
            };
        });    
    };    

})(jQuery);


    jQuery(function($){
    $('ul.news').easyPaginate({step:4});
    }); 

which is a carousel-like plugin that produces this html structure for the navigation:

<ol id="pagination" class="pagin"><li class="prev">prev</li><li data-index="1" class="">1</li><li data-index="2" class="">2</li><li data-index="3" class="current">3</li><li class="next stop">next</li></ol>

And all I want is to enclose this list in a div. Seems simple, but appendTo doesn’t want to cooperate with me, or I’m doing something wrong (I’d appreciate if you would help me understand what that is..)

So I’m modifying as such:

var ol = $('<ol id="'+ options.controls +'" class="pagin"></ol>');
var tiv = $('<div id="lala"></div>');
ol.appendTo('#lala');
tiv.insertAfter(obj);

I know how to chain, but I’m in “debugging” mode trying to understand why I don’t get the result I imagine I would get:

<div id="lala>
<ol id="pagination><li>...... </li></ol>
</div>

I tried putting some console.log’s to see the status of my variables but couldn’t find something useful.. I guess there’s something with DOM insertion I don’t get.

  • 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-06T13:57:38+00:00Added an answer on June 6, 2026 at 1:57 pm

    You’re appending the <ol> element to #lala before adding the latter to the document. There’s nothing wrong with this, but since you’re using an id selector, and the target element is not part of the document yet, the selector will not match anything.

    To fix this, you can write:

    var ol = $('<ol id="'+ options.controls +'" class="pagin"></ol>');
    var tiv = $('<div id="lala"></div>');
    ol.appendTo(tiv);
    tiv.insertAfter(obj);
    

    Or:

    var ol = $('<ol id="'+ options.controls +'" class="pagin"></ol>');
    var tiv = $('<div id="lala"></div>');
    tiv.insertAfter(obj);
    ol.appendTo('#lala');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script: Timer=0; function countdown(auctionid){ var auctions; var divs; Timer=Timer+1; if((Timer%10==0)||(Timer==1)){
Hi I have the following script in my form function pdf() { var frm
I have the following: $(document).ready(function() { var myIframe = document.getElementById('myIframe'); var element = myIframe.contentDocument.createElement('script');
I have the following script: function add_fields(link, association, content) { var new_id = new
I have the following dummy test script: function test() { var x = 0.1
I have the following script: $('#divs').children().each( function(){ //Get Id's var id = $(this).attr('id').replace('id_',''); alert(id);
I have the following script: <script> (function(d, s, id, p) { var js, ins
I have the following script: <script language=javascript> function process(v){ var value = parseInt(document.getElementById('v').value); value+=v;
I have following script: $('.news ul li').hide(); $('.news ul li:first-child').show(); function Roller() { var
I have the following script: $(#border-radius).click(function(){ var value = $(#border-radius).attr(value); $(div.editable).click(function () { mySQLinsert(value,

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.