0

i'm trying to retrieve a data value which is dynamically added by an input field. but this value is not updated with .on

<div class="box" data-box="7532 7533 7534">
    <input type="number" class="number_box">
</div>

$(document).on('keyup', '.number_box ', ' .pdt-pn', function() {

  $box = $(this).val();
  
  console.log( $(this).closest('.box').data('box'));
  
  $boxplus = $(this).closest('.box').data('box') + $box;
  $(this).closest('.box').attr('data-box', $boxplus);
});

my console.log retrieve always the same number but no with the new value. See in fiddle https://jsfiddle.net/r4kqsjga/1/

i don't anderstand ! thnak's for your help

Mike
  • 107
  • 9
  • i have found solution here https://stackoverflow.com/questions/25178380/jquery-on-keyup-change-data-attribute-value juste change data('box') by .attr(dat-box) ;) – Mike Nov 06 '21 at 14:04

0 Answers0