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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:20:25+00:00 2026-05-24T13:20:25+00:00

I’m trying to debug and I keep getting a syntax error. I’m not sure

  • 0

I’m trying to debug and I keep getting a syntax error. I’m not sure what is going on with this. I’m trying to have it where if I click on an object which is attached to “$color_cell” it pushes the atrr(“id”) into the black_colors array.

Could someone help me with this? Thanks in advance.

<script src="jquery-1.6.2.js"></script>
<script type="text/javascript">

var ids = [];
var black_colors = [];
var blue_colors = [];
var brown_colors = [];
var gray_colors = [];
var green_colors = [];
var orange_colors = [];
var pink_colors = [];
var purple_colors = [];
var red_colors = [];
var teal_colors = [];
var white_colors = [];
var yellow_colors = [];


$(document).ready(function($) {


    $(".btnColor").click(function(){

        $(".color_cell").click(function(){

            if $(this).attr("id") == "black"{

            black_colors.push($(this).attr("id"));

    }

        });

    });

});

</script>
<br>
<br>
    <button type="button" class="btnColor" id="black">Black</button>&nbsp;
    <button type="button" class="btnColor" id="blue">Blue</button>&nbsp;
    <button type="button" class="btnColor" id="brown">Brown</button>&nbsp;
    <button type="button" class="btnColor" id="gray">Gray</button>&nbsp;
    <button type="button" class="btnColor" id="green">Green</button>&nbsp;
    <button type="button" class="btnColor" id="orange">Orange</button>&nbsp;
    <button type="button" class="btnColor" id="pink">Pink</button>&nbsp;
    <button type="button" class="btnColor" id="purple">Purple</button>&nbsp;
    <button type="button" class="btnColor" id="red">Red</button>&nbsp;
    <button type="button" class="btnColor" id="teal">Teal</button>&nbsp;
    <button type="button" class="btnColor" id="white">White</button>&nbsp;
    <button type="button" class="btnColor" id="yellow">Yellow</button>&nbsp;
  • 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-24T13:20:26+00:00Added an answer on May 24, 2026 at 1:20 pm

    There are many errors in your code.

    <script src="jquery-1.6.2.js"></script>
    

    should become:

    <script type="text/javascript" src="jquery-1.6.2.js"></script>
    

    and:

    $(document).ready(function($) {
    

    should become:

    $(document).ready(function() {
    

    and:

    if $(this).attr("id") == "black"{
    

    should become:

    if ($(this).attr("id") == "black") {
    

    And also you have nested the two .click() handlers which is not correct.

    so that finally you have:

    <script type="text/javascript" src="jquery-1.6.2.js"></script>
    <script type="text/javascript">
    
    var ids = [];
    var black_colors = [];
    var blue_colors = [];
    var brown_colors = [];
    var gray_colors = [];
    var green_colors = [];
    var orange_colors = [];
    var pink_colors = [];
    var purple_colors = [];
    var red_colors = [];
    var teal_colors = [];
    var white_colors = [];
    var yellow_colors = [];
    
    $(document).ready(function() {
        $(".color_cell").click(function() {
            // Can't see any color_cell class in your markup
            // so no idea what you want to do if the DOM element with it is clicked
        });
    
        $(".btnColor").click(function() {
            if ($(this).attr("id") == "black") {
                black_colors.push($(this).attr("id"));
            }
        });
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.