javascript - Using Jquery and $(this).text() to replace th text -
i'm trying append 2 digit year column header autogenerated me. seems simple problem. have table
<table border="1" id="datatable1"> <tr> <th>jan-</th> <th>feb-</th> </tr> <tr> <td>january's data</td> <td>february's data</td> </tr> </table>
and jquery
$(document).ready( function () { var twodigityear = '14'; $('#datatable1 th').each(function () { var curtext = $(this).text(); if (curtext != "") { var newtext = curtext + twodigityear; $(this).text(newtext); } }); } );
for reason, can see value changed if put console.log in code, web page doesn't change.
here's jsfiddle: http://jsfiddle.net/pasadenajacket/ztnvr/#base
instead of datatable1
need datatable1
should work.
Comments
Post a Comment