Adding CSS style in Table using javascript -


on http://www.elitedeafpoker.com/dev/poker-players.html - ajax loads json data table , im trying add classes display background-color on 2 tags seperately , center texts, didnt work me , removed it. need table - http://www.elitedeafpoker.com/dev/img/table-example.jpg

javascript

$(document).ready(function() {     $.getjson("js/datapokerplayers.json", function(data) {         $.each(data, function(i, data){             $(".tabledata tbody").append("<tr><td>" + data.rank + "</td><td>" + data.name + "</td><td>" + data.earnings + "</td><td>" + data.points + "</td><td>" + data.totalearnings + "</td></tr>");         });     }); }); 

you can add in class="center" <td> elements want centered , use css selector style td's center class name.

jquery:

$(document).ready(function() {     $.getjson("js/datapokerplayers.json", function(data) {         $.each(data, function(i, data){             $(".tabledata tbody").append("<tr><td>" + data.rank + "</td><td>" + data.name + "</td><td class=\"center\">" + data.earnings + "</td><td class=\"center\">" + data.points + "</td><td>" + data.totalearnings + "</td></tr>");         });     }); }); 

css:

.center{     text-align: center; } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -