ajax设置字体大小,使用JavaScript更改未来元素的字体大小

899a77ab9227c0804017c514ad671af9.png

尚方宝剑之说

您只修改现有节点。如果您希望新节点采用这些规则,只需构建一个动态添加或更新css节点的javascript函数function changeSize(v){

     var css     = [

       ".message-computer p, .message-user p {font-size: "+v+"em;}"

    ].join("");

    var head    = document.head || document.getElementsByTagName('head')[0];

    var style   = null;

    if(!document.getElementById("customTextSize"))

    {

        style = document.createElement('style');

        style.id = "customTextSize";

        style.type  = 'text/css';

        style.appendChild(document.createTextNode(css));

        head.appendChild(style);

    }

    else

    {

        style = document.getElementById("customTextSize");

        style.removeChild(style.firstChild);

        style.appendChild(document.createTextNode(css));

    }}在你的改变上只需调用函数:    changeSize(v)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值