Getting values from cells in table using class. Jquery -


how can values cells in table using class? col2, col3, col4 have common class "punkty". in col5 want set result of addition col2,col3,col4. in recent solve, i'm getting string values row, example "13230", getting 13 , 23 , 0, input value 36 col5.

$("#tab tr").each(function (idx) {   var ar = $(this).find('.punkty').text();   alert(ar); } 

jsfiddle

anybody can me? :)

try this:-

fiddle

you can use text attributes function calculate sum siblings , set own text.

 $('#tab tr .suma').text(function(){    var sum = 0;      $(this).siblings('.punkty').each(function(){ //iterate through siblings calculate sum.      sum += +$(this).text();     })  return (sum==0 ? '-' : sum) ; //return '-' if no sum. }); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

php - Dynamic url re-writing using htaccess -

java - Multi-Label Document Classification -