Created
December 4, 2017 14:03
-
-
Save AladinDridi/19ec210c9a7738e1567087390439823c to your computer and use it in GitHub Desktop.
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"> | |
<style> | |
.element2{ | |
border: 1px solid black; | |
} | |
</style> | |
<title>Ajouter un élément avec le Javascript</title> | |
</head> | |
<body> | |
<div id="resultat" class="subheader"></div> | |
<script> | |
var result = document.getElementsByClassName('subheader')[0]; | |
//Création d'un nouvel élément | |
var nouveauPara = document.createElement('p'); | |
var nouvoupara2=document.createElement('a'); | |
nouvoupara2.innerHTML='cliquez ici'; | |
nouveauPara.innerHTML="Kademia est plus rapide sur sa nouvelle application : faites l'expérience" ; | |
nouveauPara.id='premierElement'; | |
nouvoupara2.id='element2'; | |
nouvoupara2.classList.add('superlink'); | |
nouveauPara.classList.add('superClasse'); | |
nouveauPara.style.fontWeight="800"; | |
nouvoupara2.setAttribute("href","https://www.kademia.tn"); | |
nouvoupara2.style.marginLeft="92 px"; | |
nouveauPara.style.color="blue"; | |
result.appendChild(nouveauPara); | |
result.appendChild(nouvoupara2); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment