HTML常用資料類型

來源:互聯網
上載者:User

標籤:

1.數學函數:Math.ceil():天花板數         //大於當前小數的最小整數Math.floor():地板數         //小於當前小數的最大整數Math.round():四捨五入取整數Math.random():產生0-1之間的隨機數  取1-36以內的數:    var s=(Math.round(Math.random()*10000000))%36+1;2.日期時間:var s = new Date();var s = new Date(1999,7,23);函數:getFullYear():擷取年getMonth():擷取月getDate(): 擷取日注意:月份取出來時需要加1。例:getHours()   擷取小時getMinutes()  擷取分鐘getSeconds()  擷取秒getDay():擷取星期setFullYear(year,month,day)  設定年、月、日setHours(hour,minute,second,ms) 設定時、分、秒toLocaleDateString():轉化為本地的日期時間格式字串3.字串length:字串的長度toLowerCase()  所有的都變為小寫toUpperCase()  所有的都變為大寫//壓縮字串中的兩端空格。*****************************************************************************************************function Trim(m){ while((m.length>0)&&(m.charAt(0)==‘ ‘)) m = m.substring(1, m.length); while((m.length>0)&&(m.charAt(m.length-1)==‘ ‘)) m = m.substring(0, m.length-1); return m; }***************************************************************************************************** indexOf("子串"):第一次出現的位置lastIndexOf("子串"):最後一次出現的位置以上兩個方法,如果父串中不包含子串,則返回-1substr("起始位置","截取長度")substring("起始位置","結束位置")

 

HTML常用資料類型

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.