Skip to content

Instantly share code, notes, and snippets.

@khitermedachraf
Created July 15, 2020 18:12
Show Gist options
  • Save khitermedachraf/a8d984f806acb1bc47375fa703bea35c to your computer and use it in GitHub Desktop.
Save khitermedachraf/a8d984f806acb1bc47375fa703bea35c to your computer and use it in GitHub Desktop.
P1C3 JS web - Modifiez le DOM
<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>
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";
article {
margin: auto;
margin-bottom: 20px;
width: 90%;
border: 1px solid black;
padding: 10px;
}
#main {
font-weight: bold;
color: red;
}
.important {
font-style: italic;
}
@khitermedachraf
Copy link
Author

manipulation if the DOM with
createElement
appendChild(newP);
.innerHTML ="Mon grand contenu";
classList.add("important");
style.color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment