jsp 正则表达式实现 文字居左,数字居右
var reg = /^\-?[\d|,]*\.?\d*%?$/;
$('#dataTable td').each(function() {
var str = $(this).text();
str = str.replace(/(^\s*)|(\s*$)/g, '');
if ('' == str) {
$(this).text('--').attr('align', 'right');
} else if ('%' == str) {
$(this).text('--').attr('align', 'right');
} else if ('--' == str) {
$(this).attr('align', 'right');
} else if (reg.test(str)) {
$(this).attr('align', 'right');
}
});
jsp:引入js
<script type="text/javascript" src="${js_path }/lib/td.js"></script>
posted on 2012-02-28 16:26 square198901 阅读(660) 评论(0) 编辑 收藏 举报