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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -