如何改变一个字符串值的CSS边距,如果value大于99内的span标签



我想更改字符串的CSS边距,当它的值为>比99在<span>标签?

我如何做到这一点?

.total_quantity {
position         : absolute;
z-index          : 1;
background-color : transparent;
font-family      : cute-font;
font-size        : 40px;
animation        : neonAnim 2s alternate-reverse infinite;
color            : #FF00F0;
/* Default Value */
margin-right     : 2px;
/* I want to change the CSS margin to the below value when it's > 99 */
margin-right     : 20px;
}
<span class="total_quantity">99</span>


我实际上是从JS函数中获取数据这是我的函数代码

function pos_total_row() {
var total_quantity = 0;
$('table#pos_table tbody tr').each(function() {
total_quantity = total_quantity + __read_number(
$(this).find('input.pos_quantity')    
);
});
$('span.total_quantity').each(function() {
$(this).html(__number_f(total_quantity));
});
}

你可以创建一个变量放到标签里面;您将在JavaScript中创建它,然后使用if语句询问变量是否为>99。然后,您可以创建另一个CSS类,一个处理>99,另一个处理<99,其中代码是相同的,除了页边距。抱歉,这样效率不高。然后根据JavaScript的if语句,将变量放入<99或>99类的标记中。

相关内容

最新更新