开发者

Wrap HTML around existing elements

开发者_运维问答

This is my normal css to apply :

<h3><strong><span style="color: #3399ff;"></span></strong></h3>

I wish to apply that style above to these js elements:

$('#no_tax_price').text("$"+no_tax_price.toFixed(2));
        $('#tax').text("$"+tax.toFixed(2));
        $('#tax_price').text("$"+(no_tax_price+tax).toFixed(2));


If you define your styles in CSS rather than HTML, your new elements will automatically take on the styling - no JS required.

#no_tax_price, #tax, #tax_price {
    font-size: 18pt;
    font-weight: bold;
    color: #3399ff;
}


Normally I wouldn't use <h3><strong><span> to apply styles (instead just use a single class with the right CSS properties defined), but a quick fix is to just wrap those elements around the contents of your "jQuery elements":

$('#no_tax_price, #tax, #tax_price')
    .wrapInner('<h3><strong><span style="color: #3399ff;"></span></strong></h3>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜