Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Well done!

You have completed (UPI) Chapter 9: Understanding the Document Object Model (DOM) with JavaScript!

Instruction

Creating Attributes

Attributes can be created using either the createAttribute() or setAttribute() function. createAttribute() works similarly to createElement() by creating the attribute only in memory. On the other hand, setAttribute() directly integrates the new attribute into an element.

Example using the <a> element with its href attribute:

// Create an <a> element
const anchor = document....