keyup - 在 keyup children child 上检索新数据到 div
问题描述
我正在尝试检索由输入字段动态添加的数据值。但是这个值没有用 .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);
});
我的 console.log 总是检索相同的数字,但没有新值。请参阅小提琴https://jsfiddle.net/r4kqsjga/1/
我不明白!谢谢你的帮助
解决方案
推荐阅读
- docker - 无法将图像从詹金斯部署到 docker
- sql - 应用程序发布后 SQL 集成安全连接字符串不起作用
- reactjs - 在 ReactJS 中编辑多个输入
- swift - 如何通过其他 2 个函数的调用函数响应传递 RxSwift zip
- html - 我的下拉菜单菜单不会排在其他元素的前面
- apache - 如何从 URL 中删除文件夹名称?
- java - 如何使用 JAXB 在 Java 中将 CSV 转换为 XML
- javascript - 编写了一个函数来隐藏一个小部件,但如果没有事件监听器就无法使其工作。我需要它在页面完全加载时运行
- java - 我不明白为什么 " if(number%i ==0) " ->(condition is always true) ...这意味着这个方法总是返回 false
- python - 在 sphinx ipython 指令中运行文件