The DOM, sounds scary but really it’s just like everything else in coding, with a little practice it’s not too bad at all.
The DOM, sounds scary but really it’s just like everything else in coding, with a little practice it’s not too bad at all. I had very little issue with this section of the class, mostly because it builds on the previous sections. Prior to this I had been using createSlider
to alter different values for given elements in a sketch like color or diameter. Including other types DOM’s is pretty straight forward remembering to create a var
to hold the information the DOM is providing is the key to making everything play nicely. Once the basic structure is setup, passing the information in is painless.
function addItem() { // Create an li element var li = createElement('li', itemInput.value()); // set li's parent to an element with id "todolist" li.parent("todolist"); li.style('color', 'cyan') }
I first used createP
which didn’t take advantage of the <ol id='orderedlist'></ol>
so I switched to createElement
and that did the trick.
Overall adding DOM’s top p5.js is pretty intuitive and i can see how there are many possible scenarios that the will be useful in the future.