如何获取span标签的值 [英] How Do I get the values of span tags
本文介绍了如何获取span标签的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< span> ID = 小计 >< /跨度>
我需要将我的span标记小计的内容发送到另一个页面,我想保存它进入一个隐藏的领域,但我发现没有办法做到这一点。
我用过这个,但没有成功!
function getTotal(){
return alert(document.getElementById('total')。innerHTML);
}
对于那些需要答案的人来说,这是正确的功能!当我想出了脚本...
function getTotal(){
//document.write(document。 。的getElementById( '总')的innerHTML);
var someValue = $(。total)。text();
alert(Value is+ someValue);
//它会导致页面重新载入并给出参数总数
location.href =frmAdd.php?total =+ someValue;
解决方案
/ p>
$(#subtotal)。text();
How Do I get the value of a span tag and send it into my form to another page?
<span id="subtotal"></span>
I need to send the content of my span tag subtotal to another page, I would like to save it into a hidden field, but I found no way to do this..
I used this, but no success!
function getTotal() {
return alert(document.getElementById('total').innerHTML);
}
Here goes the right function for those who needs the answer! After I figured out the script ...
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;
}
解决方案
this will give you value
$("#subtotal").text();
这篇关于如何获取span标签的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文