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); }
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
Post a Comment