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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:31:47+00:00 2026-05-27T01:31:47+00:00

I have four divs in my html page something like this: the working fiddle

  • 0

I have four divs in my html page something like this:
the working fiddle implementation is here: http://jsfiddle.net/GxaCK/3/

 <div class="first">
    <p> First </p>
    </div>
    <div class="second">
    <p> Second </p>
    </div>
    <div class="third">
    <p> Third </p>
    </div>
    <div class="fourth">
    <p> Fourth </p>
    </div>

and then the jquery like this:

$(function() {
    var firstCnt = 0,
        secondCnt = 0,
        thirdCnt = 0,
        fourthCnt = 0;
    $(".first").live("click", function(){
        firstCnt += 1;
        $(".first p").text(firstCnt);
    });

     $(".second").live("click", function(){
        secondCnt += 1;
        $(".second p").text(secondCnt);
    });

});

now given this, i can do firstCnt%2 to get if the div was clicked for even or the odd number of times.

I have the following doubt:
1. is this a goodway of implementation, in a project?
2. is there anything like even odd selector for clicks as well, as exists in css3

  • 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-27T01:31:47+00:00Added an answer on May 27, 2026 at 1:31 am

    For even odd..you can use toggle. See updated jsfiddle here.

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

Sidebar

Related Questions

I am setting up a page with jQuery's Cycle plugin and have four divs
I have an issue with my divs. I currently have four divs in html
I have 5 divs in my page. Father div container includes four child div.
I have four divs with custom Attributes like: <div marker=A>A1</div> <div marker=A>A2</div> <div marker=B>A3</div>
Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG
I have a single page jQuery Mobile app with four data-role='pages' in place; so,
I have four divs in a row and whichever one you click on, the
I have a four divs all set display:none and on document.ready i am showing
I have four images on a page that on hover, needs to replace the
how to get the css floating property to work with four divs? I have

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.