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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:05:14+00:00 2026-06-07T06:05:14+00:00

I have a new problem with pagination: <br><b>Page:</b><br/> <?php for($i=0; $i<$count; $i++) { if

  • 0

I have a new problem with pagination:

<br><b>Page:</b><br/>
<?php
  for($i=0; $i<$count; $i++)
  {
    if ($i==0)
    {
      echo "<div class='selected_page_button'>".($i+1)." "."</div>";
    }
    else
    {
      echo "<div class='page_button'>".($i+1)." "."</div>";
    }
  }
?>

CSS code:

.page_button {
  height:20px;
  width:15px;
  padding-left:4px;
  padding-right:4px;
  display:block;
  float:left;
  border:2px solid #000000;
  margin-right:4px;
  text-decoration:none;
  text-align:center;
  cursor: pointer;
}

.selected_page_button {
  color : #FFFFFF;
  height:20px;
  width:15px;
  padding-left:4px;
  padding-right:4px;
  display:block;
  float:left;
  margin-right:4px;
  text-decoration:none;
  text-align:center;
  background:#0088cc;
  border:2px solid #000000;
}

And code for changing class of container:

$(".page_button").click(function () {
  $(".selected_page_button").attr("class", "page_button");
  $(this).attr("class", "selected_page_button");
});

It works correctly for all containers without first. When my page is created the first page is selected. When I click by “2”, then “1” is simple and “2” is selected. The same thing is with all containers without “1”: if I click by “2” (or other one) then I can’t click by first! “1” changes it’s view but doesn’t change behavior, because simple container is clickable and selected container is not clickable!

  • 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-07T06:05:15+00:00Added an answer on June 7, 2026 at 6:05 am

    jcubic is correct with his solution but not his implementation. You need to make sure that the event is bound to all page_buttons, the ones that exist on page load and the ones that come into existence later.

    jQuery’s ‘on’ and ‘live’ functions can accomplish that. These functions bind listeners to container elements and wait for the event to bubble up to them, so that even if a page_button is added later, the event will still hit the listening container.

    Here is the correct implementation of these functions:

    $('#paginationLinkContainer').on('click','.page_button',function() {
        $('.selected_page_button').attr('class','page_button');
        $(this).attr('class','selected_page_button');
    });
    

    In this block, the listener is bound to the container (which you may need to add to your markup) and filters so that it executes only when the events source has bubbled from a ‘.page_button’.

    And for older versions of jQuery

    $('.page_button').live('click',function() {
        $('.selected_page_button').attr('class','page_button');
        $(this).attr('class','selected_page_button');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have new problem. My code: .method public static void Main() cil managed {
Well, now i have a new problem. Im writing code in C# I want
I have this new problem. I have the following code in JSF 2.0 with
I have a problem with Magento pagination. The prudct list page i call by
I have a new problem with a python script. When I try to run
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I am having a new little problem; I have a little pointer called: int
I'm new to Vim (almost new) and have some questions. The problem came from
I have problem with WPF - I'm quiet new in this smart technology. So
I have the problem I just installed the new Monodevelop 2.2.2 on Windows but

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.