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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:11:49+00:00 2026-05-27T08:11:49+00:00

In my HTML I have: <div id=cowcloud> <canvas id=cows width=1024 height=253> <p>Browser doesn’t support

  • 0

In my HTML I have:

<div id="cowcloud">
 <canvas id="cows" width="1024" height="253">
   <p>Browser doesn't support HTML5 canvas</p>
 </canvas>
</div>

I load a javascript file doing some jQuery stuff in the section using the jQuery ready function. This has the following contents:

var cattle = [ 
                 {
                      "name" : "klara88",
                      "polygon" : {
                                       "vertices": [
                                          {"x" : "138", "y" : "204"}, 
                                          {"x" : "145", "y" : "201"},
                                          {"x" : "155", "y" : "178"}, 
                                          {"x" : "208", "y" : "177"},
                                          {"x" : "216", "y" : "200"}, 
                                          {"x" : "208", "y" : "192"},
                                          {"x" : "208", "y" : "218"}, 
                                          {"x" : "196", "y" : "219"},
                                          {"x" : "195", "y" : "206"}, 
                                          {"x" : "170", "y" : "202"},
                                          {"x" : "169", "y" : "219"}, 
                                          {"x" : "150", "y" : "217"}
                                       ]
                                }
                  }, 
              ];

$(document).ready(function() {
    $('#cowcloud').click(function(e){
        [..]
        /* Search the cattle */
        $.each(cattle, function(i, cow) {
            [..]
            var context = $("#cows")[0].getContext('2d');
            context.fillStyle = '#0f0';
            context.beginPath();

            $.each(cow.polygon.vertices, function(i, vertex) {
                if(i == 0) {
                    context.moveTo(vertex.x, vertex.y);
                }
                else {
                    context.lineTo(vertex.x, vertex.y);
                }
            });
        context.closePath();
        context.fill();
        });

    });
 });

I cut some code away that was not relevant to this question.

The strange thing is that even when using the document ready function, jQuery is unable to find the canvas with id ‘cows’. Also tried using plain javascript but then the element is null. Am I missing something here?

  • 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-27T08:11:50+00:00Added an answer on May 27, 2026 at 8:11 am

    Ok this was a classical case of PEBKAC, in the code you didn’t see I had:

    $('#cowcloud').html('x: ' + point.x + ' y:' + point.y);
    

    Which replaced the canvas.

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

Sidebar

Related Questions

Suppose I have a div element with height: 150px and width:300px . Is it
I have CSS div.myButton input a { display:block; height: 24px; width: 43px; padding:10px 10px
It seems that in Firefox, if I have div A with fixed width/height and
I have a HTML DIV element: <div class=obj height=this is attr 1 rel=this is
I have a div element in an HTML document. I would like to extract
I have html like so: <div class=foo> (<a href=forum.example.com>forum</a>) <p> Some html here.... </div>
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have a div directly under the body. My HTML looks like this: <body>
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
If I have HTML content in a variable like so: var data = <div

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.