-2
Good afternoon guys, all right?
So I need a little help to make this code work.
I basically need that when it is on the page "body" and that the class of the page is "courses" the div appear, and when it is not she does not need to appear.
I wrote this code that comes to work on the Chrome console, but when I try to put it right on the site does not work... someone can give me a light on this?
I tried to do it two different ways and none worked
// Confere se tem a categoria no body e retorna um valor
var corpo = window.document.querySelectorAll("body.cursos").length;
// verifica se o valor é suficiente para a div aparecer
if (corpo >= 1) {
$('minhaDiv').show();
} else if (corpo == 0) {
$('minhaDiv').hide();
}
<body class="curso">
<div id="minhaDiv" class="col-sm-12">
<h1>TESTE</h1>
</div>
</body>
var corpo = window.document.querySelectorAll("body.cursos").length;
var some = window.document.querySelectorAll("div.minhaDiv");
if (corpo >= 1) {
some.style.display = 'block'
} else if (corpo == 0) {
some.style.display = 'none'
}
<body class="curso">
<div id="minhaDiv" class="col-sm-12">
<h1>TESTE</h1>
</div>
</body>