0

I'm fairly new to JS, and I have been looking around to find answers unsuccessfully. It may well be trivial but I must not be looking at the problem from the right angle.

I have a JS function using classie and scroll event working well (toggling classes). Now I wanted to add this following one but both FF and Chrome's consoles tell me the function isn't defined... and I couldn't find why. This snippet is in the < head > of a wordpress header template. The divs it should apply to are in the same header template (there are 2).

<script>
function openmenu() {
    var order = document.getElementsByClassName("menu-burger");
    var orderTotal = order.length;
    for(var i = 0; i < orderTotal ; i++){
        order[i].addEventListener("click", function ServeBurger() {
            Table13 = document.GetElementById("mobile-menu");
            classie.toggle(Table13, "show"));
            }
        , false);
    }
}
</script>

What am I doing wrong? Thanks in advance...

LudoC
  • 919
  • 1
  • 8
  • 16

1 Answers1

2

GetElementById should be getElementById

Kirill Pisarev
  • 844
  • 4
  • 11
  • That's right -.-' Now I don't have "not defined" anymore but the function is not toggling classes... any idea why? – LudoC Jan 22 '15 at 07:37
  • @LudoC: [Learn how to debug JavaScript](https://developer.chrome.com/devtools/docs/javascript-debugging) – Felix Kling Jan 22 '15 at 07:43
  • @LudoC try to make a [fiddle](http://jsfiddle.net/) with your problem, and btw you make `Table13` global, it is bad practice. In your case it's better to to define one local variable without loop. – Kirill Pisarev Jan 22 '15 at 07:46