A Pen by khiter med achraf on CodePen.
Created
July 15, 2020 18:12
-
-
Save khitermedachraf/a8d984f806acb1bc47375fa703bea35c to your computer and use it in GitHub Desktop.
P1C3 JS web - Modifiez le DOM
This file contains hidden or 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
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="index.css" /> | |
<script type="text/javascript" src="index.js" defer></script> | |
</head> | |
<body> | |
<div id="main"> | |
</div> | |
</body> | |
</html> |
This file contains hidden or 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 newP = document.createElement("p"); | |
const mainDiv = document.getElementById("main"); | |
mainDiv.appendChild(newP); | |
newP.innerHTML ="Mon <strong>grand</strong> contenu"; | |
newP.classList.add("important"); | |
newP.style.color = "green"; |
This file contains hidden or 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
article { | |
margin: auto; | |
margin-bottom: 20px; | |
width: 90%; | |
border: 1px solid black; | |
padding: 10px; | |
} | |
#main { | |
font-weight: bold; | |
color: red; | |
} | |
.important { | |
font-style: italic; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
manipulation if the DOM with
createElement
appendChild(newP);
.innerHTML ="Mon grand contenu";
classList.add("important");
style.color