jQuery mouse click counter

0 votes
I need to color a table in zebra style, and then when I click on the table, twice (not double click), it should change back to original.

My question is, how to count 2 clicks?
Jun 15, 2022 in JQuery by gaurav
• 23,260 points
1,224 views

1 answer to this question.

0 votes

You can use jQuery's toggleClass function for that:

$(" ... ").click(function() {
    $(this).toggleClass("someClass");
});

When clicked once, the element has the someClass class, and when clicked twice, the class is removed again.

answered Jun 16, 2022 by rajatha
• 7,680 points

Related Questions In JQuery

0 votes
1 answer

How to distinguish between left and right mouse click with jQuery

Using the mousedown() method: The mousedown() method in ...READ MORE

answered Jun 14, 2022 in JQuery by gaurav
• 23,260 points
779 views
0 votes
1 answer

How do I check if the mouse is over an element in jQuery?

Hello @kartik, Use this code: $("someelement").mouseenter(function(){ ...READ MORE

answered Oct 5, 2020 in JQuery by Niroj
• 82,840 points
2,351 views
0 votes
1 answer

How to Handle Button Click Events in jQuery?

jQuery click() Method The click event occurs when ...READ MORE

answered Jun 2, 2022 in JQuery by Edureka
• 13,690 points
2,351 views
0 votes
1 answer

How to trigger a click on a link using jQuery

If you are trying to trigger an ...READ MORE

answered Jun 3, 2022 in JQuery by Edureka
• 13,690 points
16,429 views
0 votes
0 answers

jQuery mouse click counter

I need to color a table in ...READ MORE

Aug 2, 2022 in Web Development by gaurav
• 23,260 points
677 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,322 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
15,717 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
23,302 views
0 votes
1 answer

How to trigger a click on a link using jQuery

$( "#foo" ). trigger( "click" ); As of jQuery ...READ MORE

answered Jun 10, 2022 in JQuery by rajatha
• 7,680 points
729 views
0 votes
1 answer

How to trigger a click on a link using jQuery

Use the jQuery click() Method You can use ...READ MORE

answered Jun 10, 2022 in JQuery by rajatha
• 7,680 points
1,732 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP