2017-07-30 11 views
-1

JavaScriptでフォームが表示されなくなりましたが、フォームが表示されていないときにテキスト行が表示され、javascriptの正しいブール演算子あります。javascriptを使用して要素を非表示にして表示

<script> 
 
    function Enter() { 
 
     survey.style.display = "none"; 
 
     if (survey==="none"){ 
 
      thank.style.display = "inline"; 
 
     } 
 
     else { 
 
      thank.style.display = "none"; 
 
     } 
 
    } 
 
</script>
<div id="right"> 
 
    <div id="thank" style=" display: none"> 
 
     Thank you, your message has been sent. 
 
    </div> 
 
    <form name="survey" id="survey" action="" method="post"> 
 
     <input type="submit" value="Contact Us!" onclick="Enter()"/> 
 
    </form> 
 
</div>

エラーメッセージ:

"message": "SyntaxError: expected expression, got '<'", "filename": " https://stacksnippets.net/js ", "lineno": 13, "colno": 28

+0

おそらくあなたがもし(survey.style.display試してみてください== 'なし'){ ありがとう.style.display = 'インライン'; } – Gunnrryy

+0

double equalを使用してみませんか? '==='ではなく '=='? –

+0

@PraveenKumarその問題は私のJDKは '==='期待していると言っています – briggleshiggle

答えて

0

私が正しくUを理解していれば、あなたはtekstのウィッヒのラインを持ちたい

がデフォルトである: "表示:なし" So:

<p id="MyTekst" style="display: none">My line of tekst</p> 

スクリプトであることを組み合わせる:

<script> 
function Enter() { 
    survey.style.display = "none"; 

    if (survey==="none"){ 
     thank.style.display = "inline"; 
     document.getElementById("MyTekst").style.display = "block"; 
    } 
    else { 
     thank.style.display = "none"; 
    } 
} 
</script> 

私たちは、それがこれで作業ガットそれは

+1

フォームが消えたら、まだテキスト行を表示できません。 – briggleshiggle

0

を助けたかどうかを知りましょう:

    <script> 

        function Enter() { 
         survey.style.display = "none"; 

         if (survey.style.display==="none"){ 
          thank.style.display = "inline"; 
         } 
        } 
       </script> 
関連する問題