按钮上的显示字段单击-thymeleaf

时间:2018-04-11 10:28:07

标签: html spring spring-boot thymeleaf

我正在开发一款springboot-thymeleaf TicTacToe游戏。

我想问用户以下问题。

<p>Would you like to configure the symbols you would want to play 
 with?</p>

<input type ="button" value="Yes" class="btn" name="btn_yes"/>
<input type="button" value = "No" class = "btn" name="btn_no"/>

点击“是”按钮,我想显示一个文本字段。 有人可以帮帮我吗?我是新来的。

2 个答案:

答案 0 :(得分:0)

 
         <style>
            #myDIV {
               width: 100%;
            padding: 50px 0;
            text-align: center;
            background-color: #000;
            margin-top: 20px;
            color:#fffff;
            }
            </style>
         
         <body>
            <button onclick="myFunction()">Yes</button>
           <div id="myDIV">
        Can someone please help me?
        </div>
            <script>
            function myFunction() {
                var x = document.getElementById("myDIV");
                if (x.style.display === "none") {
                    x.style.display = "block";
                } else {
                    x.style.display = "none";
                }
            }
            </script>
            </body>
        

答案 1 :(得分:0)

<强> HTML

<html>
  <head>
  </head>
  <body>
    <p>Would you like to play a game</p>
    <input type="button" value="Yes" class="btn" name="btn_yes" onclick="btnClickYes()"/>
    <input type="button" value="No" class="btn" name="btn_no"/>
  </body>
</html>

<强> JS

var amount = 0;

function btnClickYes() {
    amount += 1;  
    if (amount == 1){
      var textbox = document.createElement('input');
      textbox.type = 'text';
      document.body.appendChild(textbox);

      amount = 1;
    }   
};