2

Edit: Also should mention that I didn't write the js file...I just added the canvas.parent()line so I could integrate it with the rest of our website. This is a group project.

This might be a silly question but for some reason I can't get my canvas.parent() element to work. Any changes made to the container doesn't affect the position of the sketch on my page.

Here's the setup function from the sketch.js:

  var canvas = createCanvas(ww, hh);
  loadFlights();
  canvas.parent('visualization');
}

And here's the snippet from the HTML file:

<div class = "btns">
 <button onclick="createFlightFromForm()" class = "btn">Submit</button>
 <button onclick="save('myCanvas.jpg');" class ="btn">Save Map</button>
</div>
  
<div id='visualization'></div>

I'm very new to HTML/CSS/Javascript so any help would be appreciated!!

parchinkos
  • 21
  • 3
  • 2
    What are you trying to do? – Phix Dec 05 '21 at 22:46
  • the sketch appears at the bottom of the page, I'm trying to put it inside a div and reposition it on the page with the other content but it's not working – parchinkos Dec 05 '21 at 22:47
  • `canvas.parent('visualization');` alone... not assigned to any variable... No method applied on it... What do you expect? – Louys Patrice Bessette Dec 05 '21 at 22:47
  • what methods should I apply? all the reference posts I looked up followed the format of canvas = createCanvas and then canvas.parent(). I'm not too familiar with js – parchinkos Dec 05 '21 at 22:51
  • 1
    what are you expecting `canvas.parent('visualization')` to do? – Olian04 Dec 05 '21 at 22:55
  • put it inside `
    ` so that I can align the sketch with the other items on the webpage
    – parchinkos Dec 05 '21 at 22:57
  • followed syntax from this website, not sure what else to add: https://p5js.org/reference/#/p5.Element/parent – parchinkos Dec 05 '21 at 23:12
  • @parchinkos Welcome to Stack Overflow. If you are using a framework or library like p5js, you need to specify that in the question. Without that information we are unable to understand or run your code and that means that it is not a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) For further information, please see [how to ask good questions](http://stackoverflow.com/help/how-to-ask), and take the [tour of the site](http://stackoverflow.com/tour) – coagmano Dec 06 '21 at 03:48
  • To help answer your question: Where is the JS file loaded in the HTML? I suspect that the script is running before the div exists, and so it can't find it. – coagmano Dec 06 '21 at 03:50

0 Answers0