I have a small thing I have to make. I need to give a CSS class to a div and this has to change the insides of the div. But my button doesn't execute the onclick or something. I don't get errors in the console.
function Naampie(){
document.getElementById("ja").className += " pasta-di-mama";
}
Naampie();
.pasta-di-mama{
color: red;
font-size: 2em;
}
<!DOCTYPE html>
<html>
<head>
<title>Javascript Stuff</title>
</head>
<body>
<div id="ja">
<p>Spaghetti</p>
<p>Macaroni</p>
<p>MI</p>
<p>Pasta Kip</p>
<p>Pasta Salade</p>
</div>
<button onclick="Naampie()">Functie</button>
<!--<script src="script.js" type="text/javascript"></script>-->
</body>
</html>
Does anyone have an idea why this isn't working?
Naampie();is already called, so the div should have the classpasta-di-mamaon-load...