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

121
Views
Display elements based on instantaneous change and full or empty input on vue js

I have a very simple form that has a search-bar and two buttons. I want the fill button to be displayed if there is a value in the input and only the empty button to be displayed if there is no value in the input. I want to affect the display or non-display of the buttons instantly and with any change, whether the input is full or empty. How is this handled in Vue js?

The scenario is that in fact the fill button is displayed when the input has a value, and by pressing it, the input is empty and reset, and as a result, the button itself is non-display and the empty button is displayed. The fill button is to empty the input when it has any value.

<form class="myform">

  <button type="reset" class="fill">Show when fill </button>
  
  <button class="empty">Show when empty</button>

  <input type="search" class="myinput">

</form>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Below code should help.

   <template>
      <div id="app">
       <form class="myform">
    
          <button @click.prevent="reset" v-if="search" type="reset" class="fill">Show when fill 
          </button>
          
          <button v-else  class="empty">Show when empty</button>
    
          <input v-model="search" type="search" class="myinput">
    
        </form>
      </div>
    </template>
   <script>
    export default {
      name: "App",
      data() {
        return {
          search: null,
        }
      },
      methods: {
        reset() {
          thid.search = null;
        }
      }

    };
    </script>
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!