Change/increment title of td with for loop - JQuery -
i need assign numbers table cells, increment cell cell. have tried forloop having problem assigning incremented counter cell's title after each loop. have code -
$(function(){ var row = $('#seat_map tr:last td.freeseat') for(i=0; i<row.length; i++){ row.attr('title', i); } });
this code assigns final value of after loop has completed, cells' titles... instead of assigning '1, 2, 3' etc titles. should perhaps add together table dynamically generated using jquery also. apologies vague title , description - tried best!
thanks
well utilize .each()
anyway
var row = $('#seat_map tr:last td.freeseat'); $.each(row, function(index){ $(this).attr('title', index+1); });
but actually, straight selector.
$('#seat_map tr:last td.freeseat').each(function(index) { $(this).attr('title', index+1); });
jquery for-loop title html-table
No comments:
Post a Comment