javascript - 如果 HTMl 没有值,则无法读取文本字段值
问题描述
我正在尝试读取文本值,但由于 HTML 中没有值而无法读取,我附上 HTML plz 看看这个并建议如何读取文本值。
<table class="table table-striped">
<tr>
<td class="letter">A.</td>
<!---->
<td class="one">Length<input min="0" onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.charCode == 32 || event.charCode == 0 || event.charCode == 46" step="1" type="text" class="ng-pristine ng-valid ng-touched"> ft</td>
<!---->
<td class="two"><input max="11" min="0" onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.charCode == 32 || event.charCode == 0 || event.charCode == 46" step="1" type="text" class="ng-untouched ng-pristine ng-valid"> in</td>
在检查元素后,该值不存在于 HTML 中。
解决方案
在这些事件处理程序中,该值可以作为this.value
. this
指事件处理程序所在的元素,并且value
是包含字段当前值的属性(在 DOM 树本身中未显示)。
推荐阅读
- javascript - Javascript – 动态创建的元素上的事件委托不起作用
- swift - 为什么我的 ObservedObject 已更新但未在视图中显示其更新的内容
- java - 无法使用不同的作业名称和组运行同一类,同时运行
- python - 如何在 Python 中关闭 Discord 机器人的日志记录?
- flutter - Flutter - 索引 0、1 和 2 的节点的 Firebase RTDB 读取问题
- c - 分段错误(核心转储) - argv - c
- progressive-web-apps - 更改 Blazor 离线镀铬窗口样式
- node.js - Node.js - 监控每个进程的网络使用情况
- flutter - FutureBuilder with Provider: List 不是 Future 类型的子类型
- nginx - Nginx 配置。带有检查的磁盘文件