This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using Template literals and injecting it to the DOM with insertAdjacentHTML() method | |
let newDog = ` | |
<div class="dog"> | |
<img src="https://picsum.photos/id/237/500/500/" alt="dog"/> | |
<h2>My name is Roviel and i love playing and eating</h2> | |
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using Template literals and injecting it to the DOM with createContextualFragment() method | |
let newDog = ` | |
<div class="dog"> | |
<img src="https://picsum.photos/id/237/500/500/" alt="dog"/> | |
<h2>My name is Roviel and i love playing and eating</h2> | |
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Qui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using Template literals | |
let newDog = ` | |
<div class="dog"> | |
<img src="https://picsum.photos/id/237/500/500/" alt="dog"/> | |
<h2>My name is Roviel and i love playing and eating</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let newDog = document.createElement('div') | |
newDog.classList.add('dog') | |
const myImage = document.createElement('img') | |
myImage.src="https://picsum.photos/id/237/500/500"; | |
myImage.alt='Dog photo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dog{ | |
background-color: pink; | |
width: 40vw; | |
margin: 0 auto; | |
border-radius: 10px; | |
padding: 2rem; | |
text-align: center; | |
} | |
img{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Dog profile</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// we created a myBtn function stating that when ever we click btn, it should alert 'you clicked on the button class' | |
function myBtn() { | |
alert('you clicked on the button class') | |
}; | |
// btn class does not exist in our html page therefore this will throw an error of addEventListener of null | |
const btn = document.querySelector(".btn").addEventListener('click',myBtn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is a div with a class of container | |
<div class="container"></div> |