I have changed this hidden value by another event. Hidden value changed properly, but onchange event not working (Event not firing);
$(document).on('change', '.endDate', function() { alert($(this).val()); })
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input name="endDate" id="endDateID" type="hidden" class="form- control required bdpicker_hidden_input">
You did not set class endDate
, to trigger change event on hidden fields, you need add .trigger('change');
after set value.
$(".endDate").val(1).trigger('change');
/* $(".endDate").change(function(){ alert($(this).val()); }) */ $(document).on('change', '.endDate', function(){ alert($(this).val()); }) $(".endDate").val(1).trigger('change');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <html> <input name="endDate" id="endDateID" type="hidden" class="form- control endDate required bdpicker_hidden_input"> </html> <script> </script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.