I have a weird problem, I've written a function that works fine on jsFiddle but when i write it in my HTML nothing happens...
var el = document.querySelectorAll(".sp-methods li:first-child");
for (i = 0; i < el.length; i++) {
alert('sad')
el[i].style.display='none';
}
My Full HTML is
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script>
/*if(!window.location.href.indexOf("gpf") > 0){
alert('contains gpf, show 4-6 days');
} else {*/
var el = document.querySelectorAll(".sp-methods li:first-child");
for (i = 0; i < el.length; i++) {
alert('sad')
el[i].style.display='none';
}
/*}*/
</script>
</head>
<body>
<ul class="sp-methods">
<li class=" ">Hide me</li>
<li class=" ">Dont hide me</li>
</li>
</ul>
</body>
</html>
Yet it works here and I have no idea why?