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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:25:37+00:00 2026-05-22T11:25:37+00:00

I have a set of buttons that performs a specific action in my dynamic

  • 0

I have a set of buttons that performs a specific action in my dynamic page. I want some of this buttons to be toggle buttons, so when I click on one of them the button turns the original image into a second image, and when clicked again, the second image turns into the first again. I’ve decided that the div’s which will perform the function of my buttons are of class “.OptLvl3Tack”. I think that I can change the image using the background css property, but due to css deals only with the pseudo events hover, visited, …, but no click event, I think I have no other option than using Javascript. I have designed this code to do so:

function IfNoTacked(Tack){
    $(Tack).css("background", "url('{{ STATIC_URL }}ThumbTack_Click.png')");
    $(Tack).click(function(){IfTacked($(Tack))});
}
function IfTacked(Tack){
    $(Tack).css("background", "url('{{ STATIC_URL }}ThumbTack.png')");
    $(Tack).click(function(){IfNoTacked($(Tack))});
}   
$(".OptLvl3Tack").each(function(){$(this).click(function(){IfNoTacked($(this));})});

The code works fine, but when I click one button, let’s say, 30 times in less than 10 seconds, my computer slows down, so I have to force the web browser to be closed before my whole computer crashes. My desktop is intel i3 processor, 4gb RAM, so I think that the problem is related with the intensive use of javascript. Is it correct? or is a DOM related problem?
Is there a different way to perform this operation using javascript? not using javascript?

  • 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-22T11:25:38+00:00Added an answer on May 22, 2026 at 11:25 am

    I think you are attaching every time a new click handler. After a while your handler will be executed several times.

    Try to remove the handler or remember the state of the button in a variable and decide in the click handler what to do.

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

Sidebar

Related Questions

Here's the scenario: I have a set of buttons that I want to bind
I have a set of buttons. I want that when I do mouse up
I have a set of radio buttons. In some cases I want the user
I have a set of radio buttons that are dynamically generated (via JSON call):
I have a series of buttons that display filenames. If I set the Text
I have set the two buttons in preference.xml file. I want to go to
I have a set of buttons on one of my custom entities ribbon and
I currently have a set of buttons that I would like to set triggers
I have a flex MXML UI that is building a set of radio buttons
I have a subclassed UITableViewController that performs some animations when editing mode is entered,

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.