Matej Posted April 8, 2014 Share Posted April 8, 2014 (edited) <div id="ahoj"></div><div id="lol"></div><div id="cai"></div><button id="matek"> cau </button> function sg(){x=document.getElementById("cai");g=x.style.display;if(g=="none"){g=="block"}else{g=="none"};} window.onload=zmena;function zmena(){ document.getElementById("matek").onclick=sg;} i have set #cai{display:none;} Can you tell me whats wrong with my script and why it isnt workign? (its writting only error nothing more)// on the different IDE it writtes"none is not defined Edited April 8, 2014 by Matej Link to comment Share on other sites More sharing options...
dsonesuk Posted April 8, 2014 Share Posted April 8, 2014 1) Because it thinks none is a variable , wait you seemed have fixed it? by comparing to text 'none' or 'block' which is correct way. 2) you are not assigning 'block', 'none' to g but just comparing it again like it is use in if else condition. 3) g now equal 'none' or 'block' but you are are not applying this to the element in question. Link to comment Share on other sites More sharing options...
Matej Posted April 8, 2014 Author Share Posted April 8, 2014 Got it , thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now