Dom on Project Runway: See Her Best Designs & Runway Looks!

by Afra Jennings

Okay, so I’ve been messing around with this “DOM on Project Runway” idea, and let me tell you, it’s been a bit of a rollercoaster. I wanted to see if I could dynamically create and manipulate HTML elements like they’re fabric on a design challenge. Sounds cool, right? Well, it was, kinda, after a lot of trial and error.

Dom on Project Runway: See Her Best Designs & Runway Looks!

Getting Started: My Virtual Sewing Machine

First, I cleared out my usual coding playground – a simple HTML file with a linked JavaScript file. I needed a blank canvas, so I just had the basic HTML structure, nothing fancy.

Then, I started with the basics. I wanted to create a simple div, you know, like a basic piece of cloth. In my JavaScript file, I used

*('div')

I assigned a name by
const myDiv=*('div').

Dom on Project Runway: See Her Best Designs & Runway Looks!

This created the element, but it wasn’t visible yet. It’s like cutting the fabric but not placing it on the mannequin.

Adding Some Style: The Design Process

Next, I wanted to give my div some style. I imagined it as a vibrant red square. So, I used JavaScript to set its CSS properties:

  • * = '100px';
  • * = '100px';
  • * = 'red';

This felt like I was actually dyeing the fabric and shaping it. Still, it wasn’t on the page yet.

Putting It on Display: The Runway

To actually see my creation, I needed to add it to the webpage’s body. I did this using:

*(myDiv);

Dom on Project Runway: See Her Best Designs & Runway Looks!

Boom! There it was, my red square, proudly displayed. It was like my little digital fabric creation had made its debut.

Making It More Complex: Embellishments

I didn’t stop there. I wanted to add some text inside the div, like adding embroidery or a label. I created a text node:

const textNode = *('Hello, DOM!');

And then I attached it to my div:

*(textNode);

Dom on Project Runway: See Her Best Designs & Runway Looks!

It felt like I was adding details, making the design more intricate.

Playing Around: Alterations

The cool part was that I could change things on the fly. I decided to change the background color to blue after a few seconds. So, I used setTimeout:

setTimeout(() => {

* = 'blue';

Dom on Project Runway: See Her Best Designs & Runway Looks!

}, 2000);

It was like redesigning the garment live on the runway! I saw the square turn blue, and it felt surprisingly satisfying.

The Finished Product (For Now)

So, that’s where I’m at. I’ve got a simple, dynamically created div that changes color. It’s not exactly high fashion, but it’s a start. I can see how this could be used to build much more complex interfaces, adding and removing elements, changing styles – all with JavaScript. It’s like having a whole workshop of digital fabrics and tools at my fingertips. I think I get why people can spend time into this stuff – it’s oddly addictive!

You may also like

Leave a Comment