JavaScript how to hide and show button using dropdown options? hide show button react,hide show button jquery,hide show

I just want to hide a button defaultly and when i select any dropdown list the button comes

FIDDLE HERE

$(function() {
  $('#cashbill').change(function() {
    $('#bill_icon').hide();
    $('#bill_icon' + $(this).val()).show();
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group col-4" style="margin-bottom: 0px;">
  <label class="col-sm-12 control-label p-sm-0">Bill type :</label>
  <select class="form-control selectsch_items" name="cashbill" id="cashbill" required>
    <option value="">Choose an items</option>
    <option value="1">Raw</option>
    <option value="2">Spare</option>
    <option value="3">Others</option>
  </select>
</div>

<div class="form-group cash-billbtn">
  <label class="col-sm-12 control-label p-sm-0"></label>
  <button type="button" class="bill-btn" id="bill_icon">Bill</button>
</div>
Answer:1

Just hide the button at first , then check if no value select to hide or show ( using value length as below )

$(this).val().length ?  $('#bill_icon').show() :  $('#bill_icon').hide();

see below snippet

$(function() {
 
  $('#bill_icon').hide();
  $('#cashbill').change(function() { 
     $(this).val().length ?  $('#bill_icon').show() :  $('#bill_icon').hide();
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group col-4" style="margin-bottom: 0px;">
  <label class="col-sm-12 control-label p-sm-0">Bill type :</label>
  <select class="form-control selectsch_items" name="cashbill" id="cashbill" required>
    <option value="">Choose an items</option>
    <option value="1">Raw</option>
    <option value="2">Spare</option>
    <option value="3">Others</option>
  </select>
</div>

<div class="form-group cash-billbtn">
  <label class="col-sm-12 control-label p-sm-0"></label>
  <button type="button" class="bill-btn" id="bill_icon">Bill</button>
</div>
Answer:2

This could be done this way in jQuery:

$(function() {
    $('#bill_icon').hide();

  $('#cashbill').change(function() {
    if (this.value) $('#bill_icon').show();
    else $('#bill_icon').hide();
  });
});

But this has some problems: - If your page delays to load, it will show the button, and then it will hide it (flashing items) - This depends on JS been enabled

What I suggest you, is to hide the button on css, and then control its visibility.


What I do when I want this kind of behavior:

<label>Bill type :</label>
<select name="cashbill" id="cashbill" required>
  <option value="">Choose an items</option>
  <option value="1">Raw</option>
  <option value="2">Spare</option>
  <option value="3">Others</option>
</select>
<button type="button">Bill</button>

Hide by default on CSS, and only show it when select has a valid option:

select:invalid + button {
  display: none;
}
select:valid + button {
  display: inline-block;
}
Answer:3

I need to filter the text below from the string using Regex JavaScript: Text: 'http://www.mywebsiteameW1234.com' Should return only: mywebsitename So between character dots and only lowercase ...

I need to filter the text below from the string using Regex JavaScript: Text: 'http://www.mywebsiteameW1234.com' Should return only: mywebsitename So between character dots and only lowercase ...

  1. javascript regex filter string
  2. javascript regex filter only numbers
  3. javascript regex filter
  4. javascript regex filter special characters
  5. javascript regex filter array
  6. javascript regex filter characters
  7. javascript regex filter numbers
  8. javascript regex filter alphanumeric
  9. js regex filter
  10. js regex filter string
  11. js regex filter only numbers
  12. js regex filter array
  13. javascript filter regex match
  14. javascript regex email filter
  15. javascript xss filter regex
  16. angularjs regex filter
  17. javascript regex filter phone number
  18. regexp javascript search filter

I have json schema definition like this: (Update: basically its draft 03 format: http://json-schema.org/draft-03/schema#) { "$schema": "http://json-schema.org/draft-03/schema", "product": { ...

I have json schema definition like this: (Update: basically its draft 03 format: http://json-schema.org/draft-03/schema#) { "$schema": "http://json-schema.org/draft-03/schema", "product": { ...

  1. convert json schema to json
  2. convert json schema to openapi
  3. convert json schema to swagger
  4. convert json schema to c# class
  5. convert json schema to avro schema
  6. convert json schema to java object
  7. convert json schema to xsd
  8. convert json schema to csv
  9. convert json schema to protobuf
  10. convert json schema to swagger yaml
  11. convert json schema to typescript
  12. convert json schema to graphql
  13. convert json schema to python class
  14. convert json schema to raml
  15. convert json schema to yaml
  16. convert json schema to json data
  17. convert json schema to openapi online
  18. convert json schema to xml schema online
  19. convert json schema to avro schema online
  20. convert json schema to structtype

I am trying to render my state which updates by pulling data from an api so the initial value of the state is undefined. I am receiving the error TypeError: undefined is not an object (evaluating '...

I am trying to render my state which updates by pulling data from an api so the initial value of the state is undefined. I am receiving the error TypeError: undefined is not an object (evaluating '...

I'm making an API call in my function to fetch some data. Then I need to make multiple API calls for each item of the data returned, based on a specific value from the first call. I have a problem ...

I'm making an API call in my function to fetch some data. Then I need to make multiple API calls for each item of the data returned, based on a specific value from the first call. I have a problem ...

  1. multiple calls with no answer
  2. multiple calls with facetime
  3. multiple calls with skype
  4. multiple calls with whatsapp
  5. multiple calls on iphone
  6. multiple calls on duo
  7. multiple calls on one phone line
  8. multiple calls on google duo
  9. multiple calls from no caller id
  10. multiple calls from unknown numbers
  11. multiple calls from different numbers
  12. multiple calls from same area code
  13. multiple calls from apple support
  14. multiple calls from social security administration
  15. multiple calls from private number
  16. multiple calls from my own number
  17. multiple calls from unknown caller
  18. multiple calls from apple inc
  19. multiple calls from same number
  20. multiple calls from restricted number