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.

see updated fiddle here


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -