jquery - Update value of input using javascript -
on page im working on, there lot of hidden inputs:
<input a1="2" a2="1" a3="3" name="value" type="hidden" value="10"> <input a1="4" a2="2" a3="6" name="value" type="hidden" value="12"> <input a1="6" a2="3" a3="9" name="value" type="hidden" value="14"> ...
using following javascript want update value of inputs:
<script type="text/javascript"> $('[name="value"]').on('input', function () { $('[a1="' + $(this).attr('ds') + '"]').value = $(this).val(); }); </script>
however want update values inputs have both a1 , a2 equal $(this).val()
you need simple test check if both a1
and a2
equals $(this).val()
.
this code need:
$('[name="value"]').on('input', function () { if($(this).attr("a1") == $(this).val() && $(this).attr("a2") == $(this).val()){ $('[a1="' + $(this).attr('ds') + '"]').value = $(this).val(); } });
Comments
Post a Comment