如何获取 span 标记的值并将其发送到我的表单到另一个页面?
<span id="subtotal"></span>
我需要将我的 span 标签小计的内容发送到另一个页面,我想将它保存到一个隐藏字段中,但我找不到办法..
我用过这个,但是没有成功!
function getTotal() {
return alert(document.getElementById('total').innerHTML);
}
这里为那些需要答案的人提供了正确的功能!在我弄清楚脚本之后......
function getTotal() {
//document.write(document.getElementById('total').innerHTML);
var someValue = $(".total").text();
alert("Value is "+someValue);
//It cause to releoad the page and give me the parameter total
location.href="frmAdd.php?total=" + someValue;
}
最佳答案
这会给你带来值(value)
$("#subtotal").text();
关于javascript - 如何获取跨度标签的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4280528/