javascript - On click not working? -


On each page of the website, there are different classes for each page in the menu that take up menu image up and down It shows that the selected is selected.

When the page is infected with pageization, to give me the impression of fast loading, instead of waiting for the next page, I will have to use JS to position the background image immediately.

It does not seem to work, and I have kept the warning code to see if this function is also loading, but it

FIDDLE:

>

HTML:

  
  • gt; & Lt; A href = "index.html" onclick = "javascript: menuchange ('1');" & gt; Home and lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "what-we-do.html" onclick = "javascript: menuchange ('2');" & Gt; What we do & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "our-clients.html" onclick = "javascript: menuchange ('3');" & Gt; Our Customers & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "testimonials.html" onclick = "javascript: menuchange ('4');" & Gt; Testimonials & lt; / A & gt; & Lt; / Li & gt;
  • JS:

      Function menu ($ item click) {document.getElementById ("menu"). ClassName = "Page" & Amp; $ Itemclicked; Warning ("The code has been started!"); }  

    You can not "page" + $ itemclicked , not "Page" & amp; $ Itemclicked .

    document.getElementById ("menu"). ClassName = "page" + $ itemclicked;

    & amp; is a Javascript, which does a bitword and returns two numbers, two numbers, "Page" & amp; 1 return 0 .


    Comments