My jQuery code does not work properly while writing the right code in jQuery. When apply On change, it not working on some dynamically inserted Input field in jQuery
I am trying with this code:
HTML Code:
<input type="number" name="pot" class="pot salestarget">
JQuery Code:
<script type="text/javascript"> $('input.salestarget').each(function () { $(this).change(function () { alert(); }); }); </script>
Use jquery.min.js while you are trying with jQuery code.
If you not apply the jquery.min.js link, then apply this CDN link.
<script src="//code.jquery.com/jquery-2.2.1.min.js"></script>
If you code not working after applying jquery.min.js link, then apply this code to get proper result.
<script type="text/javascript"> $(document).on("change paste keyup",'input.salestarget' ,function() { var salestarget = $(this).val(); console.log(salestarget); }); </script>
Question and answer is powered by AnsPress.io