在线等~如何用js给指定id添加样式?

2025-03-31 04:56:15
推荐回答(2个)
回答1:





last.html

  #end2{
    color:#a00000; 
font-size:20px; 
font-weight:700; 
  }


    Date.prototype.diff = function (date)
    {
        return (this.getTime () - date.getTime ()) / (24 * 60 * 60 * 1000);
    }
     
    onload = function ()
    {
        var now = new Date ('2015/02/19 00:00:00');
        var date = new Date ();
        var diff = now.diff (date);
        document.getElementById ('end2').innerHTML = Math.floor (diff);
    }



    距过年
     天

回答2:

$("#end2").css({"color":"#a00000"},{"fontSize":"20px"},{"fontWeight":"700"});