Wednesday, 15 August 2012

Css attribute not changing (javascript) -


I am trying to create a piece of code that will change the content of my webpage by clicking on the link. It hides the div now and alters it with any other.

This is html:

  & lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "#" id = "Overview_button" & gt; Overview & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "javascript: changecontent ('background');" & Gt; Background & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "box_button" & gt; Boxes & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "color" & gt; Color & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "navigation_button" & gt; Navigation and lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "posing_button" & gt; Positioning & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "text_button" & gt; Text & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" & gt; Conclusion & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;  

The function is only applied to another element, because I'm testing it on it. The ID refers to a div later in the 'background' text.

Javascript is:

  var currentContent = 'observation'; Function TransformationNews (New Resource) {document.getElementById (Current Resource) .style.display = "none"; Document.getElementByID (newContent) .style.display = "block"; CurrentContent = newContent; };  

It successfully hides old content, but does not show new ones.

should be document.getElementByID

  document.getElementById  

Anyway, you should check the errors in your console before posting such questions.


No comments:

Post a Comment