how best to set text alignment in a table

Posted by ericslaw on Stack Overflow See other posts from Stack Overflow or by ericslaw
Published on 2010-05-14T19:12:19Z Indexed on 2010/05/14 19:14 UTC
Read the original article Hit count: 266

Filed under:
|
|
|

Does anyone know of a jquery plugin or snippet that will auto-text-align cells in a table based on content?

Specifically, all table cells would be right justified unless there is a visible non-number related character in the cell, then it would be left justified. I'd like to use something like this regular expression to identify non-number related characters in a cell:

/[^0-9% +-()]/ 

Is there a real simple way to accomplish this? I would think something like this:

$("td:contains('[^0-9% +-()]')").addClass("left");

would do the trick, but I don't think 'contains' can take a regular expression.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about plugin