Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
jQuery function is not working in PHP once the page is refreshed

I want to "Hide" the table during the starting of page, which is working using $(document).ready(function(){$("#result").hide();}); But I also want to "show" the table once the submit button is clicked, which is not working.

This is the PHP file, as I have to add more PHP code afterwards. Same result if I change this to HTML thou.

<!DOCTYPE html>
<html lang ="en">
       <head>
              <title>  Show Specific </title>
              <meta charset = "utf-8">
              <link rel="stylesheet" type="text/css" href="css/style.css">
              <script
                     src="https://code.jquery.com/jquery-3.6.0.min.js"
                     integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
                     crossorigin="anonymous">
              </script>

              <script>
                     $(document).ready(function(){
                            $("#result").hide();
                     });
                     $(document).ready(function(){
                            $("#button").click(function(){
                                   $("#result").show();//result
                            });
                     });
              </script>
       </head>
       <body>   
    
            <hr>
              
            <div id="appointment">
                <form>
                    Test ID: <input type="text" name="testID" /> <br><br>
                    First Name : <input type="text" name="First_Name" /> <br><br>
                    Last Name : <input type="text" name="Last_Name" /> <br><br>
                    <input id="submit" type="button" value="Submit" ><br><br>
                </form>
            </div>
                
            <div id="result">
                <table>
                    <tr> 
                    <th>Test ID</th>
                    </tr>

                    <tr>
                    <th>First Name </th>
                    </tr>

                    <tr>
                    <th>Last Name</th>
                    </tr>
                </table>
            </div>
                        
            <hr>

            <div id="footer">
                <footer>   Copyright &copy; ALL RIGHTS ARE RESERVED. </footer>
            </div>

       </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you look carefully, the id of your input button is submit not button as you have written on your jQuery event handler.

Change your script to this one:

<script>
$(document).ready(function(){
     $("#result").hide();
     $("#submit").click(function(){
        $("#result").show();//result
     });
});
</script>

Also: it is not necessary for you to have two $(document).ready() methods. Just implement one, and then add your function inside.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda