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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:43:50+00:00 2026-05-16T02:43:50+00:00

I have what seems to be a simple issue. I have a jquery function

  • 0

I have what seems to be a simple issue. I have a jquery function that’s running on page load, despite the fact that I specifically set it to run after the ‘click’ event on a specific element.

This is the function:

    $('#boxShow').click(function() {
      $('#colorBox').animate({
        height: 'toggle'
      }, 400, function() {
        // Code that will run after the click
      });
    });

Is there a way to prevent this code from running before the ‘click’ event? Thanks!

EDIT:

The full jquery code:

$(document).ready(function() {  

    $("#accordion").accordion({
        event: "click"
    });

    $("#TagsSelectBox").multiSelect({ 
        minWidth:130,
        selectedList:5,
        showHeader:false
    });

    $('#boxShow').click(function() {
        $('#colorBox').animate({
        height: 'toggle'
        }, 400, function() {
            // Animation complete.
        });
    });

    $('#test').colorPicker({            
        defaultColor: 0, // index of the default color (optional)
        columns: 13,     // number of columns (optional)  
        click:function(c){
        $('#boxShow').css("background-color",c);
      } 
    });
});

EDIT:
Just in case anyone wants to know, here’s the final version after making a few adjustments to make it generic enough for multiple ‘color-pickable’ items:

Final Version

If you want to try it out yourselves, you can download the color picker plugin from the syronex site. The link is in the comments!

Thanks to everyone who helped me achieve this!

  • 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-16T02:43:51+00:00Added an answer on May 16, 2026 at 2:43 am

    If I had to guess I’m not sure of what your colorpicker plugin is, so I would say try commenting out the lines that say click on that control, because it might initiate a click to that control

    $('#test').colorPicker({             
        defaultColor: 0, // index of the default color (optional) 
        columns: 13,     // number of columns (optional)   
        //click:function(c){ 
        //$('#boxShow').css("background-color",c); 
      //}  
    }); 
    

    Since it seems as if all your tags are divs, try changing the click event function to this

    $('div').click(function(e) { 
      var $target = $(e.target); 
    
      if ($target.is('#boxShow')) { 
           $('#colorBox').animate({ 
            height: 'toggle' 
            }, 400, function() { 
            // Code that will run after the click 
          }); 
    
      } else { 
        // do actions for a click anywhere else inside div
        e.preventDefault(); 
      } 
    }); 
    

    If that works then something else is wrong with your code that you have posted.

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

Sidebar

Related Questions

I have simple AJAX function that uses jQuery to return an array of 300
This seems like a simple problem: I have a WF4 activity that guides the
This seems like an incredibly simple issue but I have no idea why I'm
I have a simple javascript (JQuery based) method that does some css magic to
I have created a custom jQuery plugin that does some simple image resizing for
I am trying to perform a simple JQuery AJAX page load within a CodeIgniter
I'm trying to run bundle install and it seems to have an issue with
I have an issue that only seems to affect Safari and Chrome (aka WebKit).
I have a simple jQuery fadeIn/Out script here: $(document).ready( function(){ $(#home li).hover( function(){ $(img,
I have what seems like a simple arrangement: a list of tags in a

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.