JS DOM: 14. Membuat attribute
by istiq20
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Attribute</title>
</head>
<body>
<img id="logo" alt="PZN Logo" />
<script>
const logo = document.getElementById("logo");
// cara 1: membuat attribute
// const src = document.createAttribute("src");
// src.value = "https://www.programmerzamannow.com/img/pzn.png";
// logo.setAttributeNode(src);
// cara 2: membuat attribute
logo.setAttribute("src", "https://www.programmerzamannow.com/img/pzn.png");
</script>
</body>
</html>