Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
How to not hide my form element after submission if its css display style was set to none previously

$(()=>{

    $("#c").click(function loop(event){

        $("#a").show(1000).submit(function(event){

            if ($("#b").val() === "hello"){

                    $("#a").hide(1000);

                }

            else{
                
                    alert($("#b").val() + " was typed!");
            }
        });
    });
});
    #a{
        display: none;
    }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="a"> name : <input type="name" id="b" value="type 'hello' to hide!"></form>
    <button id="c">do it!</button>

In the above snippet I don't want the input box to disappear from screen when anything other than hello is typed! It should display the message $("#b").val() + " was typed!" but shouldn't hide.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hope this helps.

It was not actually hidden, rather the DOM itself was removed.

$(()=>{

    $("#c").click(function loop(event){

        $("#a").show(1000).submit(function(event){

            event.preventDefault();

            if ($("#b").val() === "hello"){

                    $("#a").hide(1000);

                }

            else{
                
                    alert($("#b").val() + " was typed!");
            }
        });
    });
});
    #a{
        display: none;
    }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="a"> name : <input type="name" id="b" value="type 'hello' to hide!"></form>
    <button id="c">do it!</button>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!