2013-07-18 3 views
1

나는 입니다. JavaScript에 문제가 발생했습니다. "btn"이 보이지 않지만 (숨겨진) 웹 페이지를 열면 mousedown까지 볼 수 있어야합니다. 스크립트는 다음과 같습니다.자바 스크립트 및 인터넷 정보

웹 페이지를 실행하면 btn이 숨겨집니다 ... 도와 주시겠습니까?

UPD 1 개 HTML 코드와 CSS 코드 :

<!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 { 
    from { 
     transform: rotateX(40deg); 
    } 
    to { 
     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 { 
    from { 
     transform: rotate(360deg); 
    } 
    to { 
     transform: rotate(0deg); 
    } 
} 

나는이 웹 사이트도에게 새로운 해요!

+1

CSS로 숨 겼습니까? – adeneo

+0

아니요, HTML (CSS가 아닌) JavaScript에 문제가 있습니다. –

+0

'document.onclick = RacketClick' &&'btn.onmousedown = Start' – rab

답변

3

당신은 괄호없이 기능 할당을 사용해야합니다 ... 난 당신의 답변을 좋아하는 것,하지만 난 투표 명성을하지 않습니다

btn.onmousedown = Start; 

그렇지 않으면 기능 Start이 할당과의 순간에 실행되었다 당신의 버튼이 즉시 숨겨집니다.

btn.onmousedown = Start(); 

당신은 함수 시작을 실행하고 btn.onmousedown에 결과 (undefined)를 할당됩니다

+0

좋은 눈 !!! – adeneo

+0

감사합니다. 그것은 효과가있다! 나는 그렇게 ... 결코 신경 쓰지 마시고, 감사합니다. –

1

이 줄은 당신의 문제입니다. 다음을 가져야합니다 :

괄호없이 함수를 호출하고 함수를 호출하지 말아야합니다.

관련 문제