1

I'm a complete beginner doing the odin project working on a task and I've hit a wall and was wondering if anyone could help.

Essentially, I'm trying to make an etch a sketch using jquery and javascript, it can be found here:

http://zackvs.github.io/etchasketch/

source here:

https://github.com/zackvs/etchasketch

After clicking the play buton, the problem i'm having is:

I want to start a path in the middle of the canvas and so as a first step i'm trying to find the height and width of the canvas which i'm testing using:

    "console.log($('#draw').width() + " x " + $('#draw').height);"

The console displays the width perfectly but for the height returns a v. long string which means absolutely nothing to me (starting with: "(d,e){var f=arguments.length&&(c||"boolean"!=typeof d)," etc etc).

Why is this happening?

I'm completely in over my head so any help would be appreciated, I've had a good old google but to no avail.

((Also as a sidenote I spent a lot of time trying to make the site resposive but on resizing the layout slowly comes out of line? I'm sure I've done the whole thing in a silly way with the percentages but how else can i do it?))

Thanks! sorry for long q but it's my first ever here.

1 Answer 1

1

You could do this:

var canvas = document.getElementById("canvas");
var width = canvas.width;
var height = canvas.height;

This is just the Javascript way to do it. You could try it and see if it works for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.