目录                                        

1.单行文本的溢出显示省略号

2.刷新页面

3.格式化时间

4.检索 indexOf()

5.数组元素的添加

 

 

 

 

 

 

 

 



 

1、单行文本的溢出显示省略号

overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;

2、刷新页面

window.location.reload(true) //浏览器重新从服务器请求资源,在http请求头中不会包含缓存标记。

3、格式化时间

Date.prototype.format = function(split) {
    split = split || "";

    if(split === 'time') {
        return _(this.getHours()) + ':' + _(this.getMinutes()) + ':' + _(this.getSeconds()); /*返回  时:分:秒*/
    } else {
        var month = this.getMonth() + 1;
        month = month < 10 ? "0" + month : month;
        var day = this.getDate();
        day = day < 10 ? "0" + day : day;

        return this.getFullYear() + split + month + split + day; /*返回  年月日*/
    }
}

4、检索 indexOf()

indexOf() 方法对大小写敏感!
如果要检索的字符串值没有出现,则该方法返回 -1。

5、数组元素的添加 

arrayObj.push([item1 [item2 [. . . [itemN ]]]]); // 将一个或多个新元素添加到数组结尾,并返回数组新长度  
arrayObj.unshift([item1 [item2 [. . . [itemN ]]]]); // 将一个或多个新元素添加到数组开始,数组中的元素自动后移,返回数组新长度  
arrayObj.splice(insertPos,0,[item1[, item2[, . . . [,itemN]]]]); //将一个或多个新元素插入到数组的指定位置,插入位置的元素自动后移。 

 

相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-09-17
  • 2021-08-27
  • 2021-08-22
  • 2021-09-17
猜你喜欢
  • 2021-12-30
  • 2021-08-24
  • 2021-05-25
  • 2021-05-31
  • 2021-05-24
  • 2022-02-23
  • 2021-11-09
相关资源
相似解决方案