javascript - 如何在 Laravel 中包装 JavaScript 跨度 ID
问题描述
我想发送跨度ID。我已经在刀片文件中尝试了这些代码,但我无法获得价值。请教我怎么写代码好吗?
<input type="hidden" name="quantity" value="<span id="quantity"></span>">
和
<input type="hidden" name="quantity" value="<span id="quantity"></span>">
更新
我写了这个但是“数量”值是这个“”
const priceAch = comma(parseInt(String(typeValue * productValue * quantity)));
document.getElementById('edit-quantity').value = priceAch;
解决方案
如果我误解了你的问题,请原谅我,但如果你试图让你的 span 标签之间的 HTML 值成为你隐藏输入的值,你可以按照以下方式做一些事情:
<span id="quantity">23</span>
<input id="edit-quantity" type="hidden">
<script>
document.getElementById('edit-quantity').value = document.getElementById('quantity').innerText;
</script>
这会将输入元素的 value 属性设置为 span 标签之间的文本。在上述场景中,输入值将返回“23”。
推荐阅读
- javascript - 更改后,日期选择器验证不起作用-BootStrap
- module - 编程中源代码和代码的不同含义是什么?
- python - Python Pandas to_csv,能不能用.replace() 抢先处理双引号转义问题
- java - 为什么我无法使用 StringTokenizer 访问第二个令牌?
- r - 如何覆盖@运算符以访问 R 中 S4 对象的插槽
- database - mongorestore时MongoDB如何处理Object ID重叠?
- matlab - 梯度下降 - 逻辑回归 - 奇怪的 thetas
- excel - 粘贴新数据时 Excel 表格公式范围错误地递增
- android-studio - 尝试运行 Android 应用程序时出现 INSTALL_FAILED_MISSING_SHARED_LIBRARY 错误
- postgresql - 在 Windows 上为 PostgreSQL 注册事件日志时出错