I need every div with class “comparison” to use the same javascript code
my code:
<!DOCTYPE HTML>
<html lang="pl">
<head>
<link rel="stylesheet" href="style.css">
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>Grzegorz Wierzbicki - </title>
<meta name="description" content="PLACEHOLDER"/>
<meta name="keywords" content="Wykładziny, Wykładziny, Bronowice, Kraków, wykładziny kraków, robota ręczna, zatrudnij, na zlecenie, profesionalna, profesionalny, ">
<style>
footer {
color: white;
}
</style>
<body>
<div class="container" id="container">
<!----------------------------HEADER---------------------------->
<header class="page-header">
<nav>
<a href="">
<img width="178" height="38" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/horizontal-logo-mobile.svg" alt="forecastr logo">
</a>
<button type="button">
KONTAKT
<path d="M7.411 21.39l-4.054 2.61-.266-1.053c-.187-.744-.086-1.534.282-2.199l2.617-4.729c.387 1.6.848 3.272 1.421 5.371zm13.215-.642l-2.646-4.784c-.391 1.656-.803 3.22-1.369 5.441l4.032 2.595.266-1.053c.186-.743.085-1.533-.283-2.199zm-10.073 3.252h2.895l.552-2h-4l.553 2zm1.447-24c-3.489 2.503-5 5.488-5 9.191 0 3.34 1.146 7.275 2.38 11.809h5.273c1.181-4.668 2.312-8.577 2.347-11.844.04-3.731-1.441-6.639-5-9.156zm.012 2.543c1.379 1.201 2.236 2.491 2.662 3.996-.558.304-1.607.461-2.674.461-1.039 0-2.072-.145-2.641-.433.442-1.512 1.304-2.824 2.653-4.024z" />
</svg>
</button>
</nav>
</header>
<!---------------------------Contents----------------------------->
<div id="comparison1">
<script src="comparison.js"> defer</script>
<figure>
<div id="divisor"></div>
</figure>
<input type="range" min="0" max="100" value="50" id="slider" oninput="moveDivisor()">
</div>
<div id="comparison2">
<figure>
<div id="divisor"></div>
</figure>
<input type="range" min="0" max="100" value="50" id="slider" oninput="moveDivisor()">
</div>
Dont mind the images they are just placeholders but i need them to use the same javascript code which
“comparison.js”
I tried putting
defer
but it doesnt work for any of the divs
i just expect to somehow assign the comparison. js to many divs and make all of them work
New contributor
loXXi 84 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3