Declare variable outside of the function…
var oneVariable;
function setVariable(){
oneVariable = "Variable set from within a function!";
}
function getVariable(){
alert(oneVariable); // Outputs "Variable set from within a function!"
}
Or… attach it to the window object
function setValue() {
window.myValue = "test";
}
function getValue() {
alert(window.myValue); // "test" (assuming setValue has run)
}
don’t even need to specify “var” when you are declaring a global.
It’s a good practice use the “var” keyword.
It’s bad practice to declare globals…
ok, but some Time it’s absolutely necessary.
I have problem in css global variable assigning, is it correct? but it not working how to fix this?
………………………
@D:280px;
@R:(@D/2); // radio
[email protected]:(@D/2); // radio
@B:(@R/8);
[email protected]:(@R/8);
@O: 0.6; // opacity
[email protected]: 0.6;
@A: 2s; // accelerate
[email protected]: 2s;
html,
body{
height: 100%;
}
body{
overflow: hidden;
}
.hoja{
color: rgb(220,220,226);
position:absolute;
top:50%; left:50%;
-webkit- margin-left:[email protected];
margin-top:[email protected];
width:@D;
height:@D;
text-align:center;
font-family: ‘Open Sans’, sans-serif;
font-size:@R/4;
line-height:@D;
-webkit-font-smoothing: antialiased;
}
…………………………..