1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=<device-width>, initial-scale=1.0">
<style>
.div-1 {
width: 500px;
height: 50px;
background-color: aqua;
}
.p2 {
width: 150px;
line-height: 25px;
}
</style>
</head>
<body>
<div>
<div class="div-1 div-1-1" style="color: red;"></div>
<div class="div-2 div-2-2" style="width: 100px; height: 20px; background-color: black; color: white;">
<p class="p-2" style="font-weight: bold;">Salut</p>
</div>
</div>
<textarea class="textareaClass" id="mytextarea" cols="120" rows="20"
style="background-color: antiquewhite; font-size: 1.2em;"></textarea>
<script>
function findElements() {
let bodY = document.getElementsByTagName('body')[0],
textareA = document.getElementById('mytextarea'),
infos
textareA.value = null
textareA.readOnly = true;
for (let balise of bodY.querySelectorAll('*')) {
if (balise.classList.length && balise.style.cssText.length) {
infos = `Balise: ${balise.tagName}\nclass: ${balise.classList}\nStyle: ${balise.style.cssText}\n\n`
textareA.value += infos
}
}
}
findElements()
</script>
</body>
</html> |
Partager