html JS 获取tr/td 表单元素下面的各个值

如题所述

第1个回答  推荐于2018-04-08
这是获得每个tr 中td 的内容
<script>
$('#myTableProduct tr').each(function(index,ele){
$(this).find('td').each(function(index,ele){
alert($(ele).html());
})
})
</script>
不用谢我

------君少本回答被网友采纳
第2个回答  2014-08-19
var aa=0;
$(".shopping_product_list_2").find("label").each(function(){
aa=aa+parseInt($(this).text());//最后得到的aa就是总的单品积分,其它列类似
});追问

但是还要获取后面的个数啊

追答

var aa=0;
$(".shopping_product_list").each(function(){
var jf=parseFloat($(this).find(".shopping_product_list_2 label").text());//单品积分
var iNum=parseInt($(this).find(".shopping_product_list_5 input").val());//数量
aa+=jf*iNum;//最后得到的aa就是总的单品积分,其它列类似

});

本回答被提问者采纳
第3个回答  2014-08-19
通过document.getElementById(" **").value获取单元格的数值,进行计算,获得结果。
一共节省金额=(市场价-当当价)*数量;
金额总计=当当价*数量+……
积分=单品积分*数量+……+……
用循环语句……追问

能有具体代码?

追答

jQuery~~~

第4个回答  2014-08-19
$('td').each(function(){
   // var child = $(this).children()[0].tagName;
    //if(child == )
    $(this).children()[0].html()//这个就是值了
})

第5个回答  2014-08-19
用jquery行么追问

的确用Jquery

相似回答