In a HTML file i load a javascript file (in the header) which contains some code. In that code it checks if a cookie exists. If the cookie doesn't exists it should add a class to a div which should be matched with a class.
Example:
The class where it should add the class:
<header class="firstClass">
The javascript:
var classcode = document.getElementsByClassName("firstClass");
if (myCookie == null) {
add class "secondClass" to "firstClass";
}
I've tried several things but I can't get it to work...
I should mention, the javascript file is loaded before the div where the class should be added.
Aucun commentaire:
Enregistrer un commentaire