html - JavaScript and Visibility -


i'm new javascript , i'm having problem: when launch webpage "btn" invisible (hidden), need visible until mousedown. here script:

var start= false; var racket = document.getelementbyid("racket"); var btn = document.getelementbyid("btn"); btn.style.visibility = "visible"; btn.onmousedown = start();  function start() {     btn.style.visibility = "hidden";     start = true;     document.onclick = racketclick(); }  function racketclick() {  } 

when launch webpage, btn hidden... can me?

upd 1 html code , css code:

<!doctype html> <html>     <head>         <meta http-equiv="content-type" content="text/html; charset=utf-8"/>         <meta charset="utf-8" />         <title>main</title>         <link href="/css/default.css" rel="stylesheet" />         <script src="/js/mymain.js"></script>     </head>     <body>         <div id="racket"></div>         <div id="btn"></div>     </body> </html>  #racket {     top: 100%;     margin-top: -200px;     left: 50%;     margin-left: -77px;     position: absolute;     background-image: url('/images/racket.png');     width: 154px;     height: 250px;     animation-name: racketanimation;     animation-iteration-count: infinite;     animation-delay: 0s;     animation-fill-mode: forwards;     animation-duration: 4s;     animation-timing-function: linear;     animation-direction:alternate; }  @keyframes racketanimation {     {         transform: rotatex(40deg);     }     {         transform: rotatex(55deg);     } }  #btn {     top: 50%;     left: 50%;     position: absolute;     margin-top: -128px;     margin-left: -128px;      height: 256px;      width: 256px;     background-image: url('/images/playnowborder.png');     animation-iteration-count: infinite;     animation-delay: 0s;     animation-fill-mode: forwards;     animation-duration: 10s;     animation-name: clicken;     animation-timing-function: linear; }  @keyframes clicken {     {         transform: rotate(360deg);     }     {         transform: rotate(0deg);     } } 

i'm new website too! liked answers, don't have reputation vote...

you should use function assignment without parenthesis:

btn.onmousedown = start; 

otherwise function start got executed @ moment of assignment , button becomes hidden immediately.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -