I’m just learning the WordPress structure and javascript/php so I’m hoping someone can help me figure this problem out.
What I’m trying to do is display a div I’ve placed in my header.php, but only when it’s the ‘index.php’ file that is loaded.
Shouldn’t it look like this?
$(document).ready(){
if.this(document == "http://sample.com/") {
this.document.getElementById('only-show-when-index').style.display = "visible";
} else {
this.document.getElementById('only-show-when-index').style.display = "hidden";
}
};
You have some syntax errors, and you’re not in a context where ‘this’ will work: