JavaScript常用方法總結

來源:互聯網
上載者:User
javascript常用方法總結

 

Js代碼 {
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
dp.sh.Toolbar.CopyToClipboard(this);return false;
}
}
}
}
}
}" href="http://writeblog.csdn.net/#">
  1. /**  
  2.  * 字串的trim方法  
  3.  * @return  
  4.  */  
  5. String.prototype.trim = function(){    
  6.     return this.replace(/(^/s*)|(/s*$)/g, "");   
  7. }    
  8. String.prototype.ltrim = function(){    
  9.     return this.replace(/(^/s*)/g, "");    
  10. }    
  11. String.prototype.rtrim = function(){    
  12.     return this.replace(/(/s*$)/g, "");    
  13. }    
  14. function isBlank( s ){   
  15.     if( s == null || s.trim() == ''){   
  16.         return  true ;   
  17.     }   
  18.     return false ;   
  19. }  
/** * 字串的trim方法 * @return */String.prototype.trim = function(){ return this.replace(/(^/s*)|(/s*$)/g, "");} String.prototype.ltrim = function(){ return this.replace(/(^/s*)/g, ""); } String.prototype.rtrim = function(){ return this.replace(/(/s*$)/g, ""); } function isBlank( s ){if( s == null || s.trim() == ''){return  true ;}return false ;}

 

 

Js代碼 {
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
dp.sh.Toolbar.CopyToClipboard(this);return false;
}
}
}
}
}
}" href="http://writeblog.csdn.net/#">
  1. /**  
  2.  * 全選與全不選功能  
  3.  * @param mark 指示全選還是反選  
  4.  * @param name 對應的HTML元素的name  
  5.  * @return  
  6.  */  
  7. function selectAll(mark , name) {   
  8.     var checkboxs = document.getElementsByName(name);   
  9.     if (mark){   
  10.         for (var i=0; i<checkboxs.length; i+=1) {   
  11.             checkboxs[i].checked = true;   
  12.         }   
  13.     }else{   
  14.         for (var i=0; i<checkboxs.length; i+=1) {   
  15.             checkboxs[i].checked = false;   
  16.         }   
  17.     }   
  18. }  
/** * 全選與全不選功能 * @param mark 指示全選還是反選 * @param name 對應的HTML元素的name * @return */function selectAll(mark , name) {var checkboxs = document.getElementsByName(name);if (mark){for (var i=0; i<checkboxs.length; i+=1) {checkboxs[i].checked = true;}}else{for (var i=0; i<checkboxs.length; i+=1) {checkboxs[i].checked = false;}}}

 

 

 

Js代碼 {
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
dp.sh.Toolbar.CopyToClipboard(this);return false;
}
}
}
}
}
}" href="http://writeblog.csdn.net/#">
  1. /**  
  2.  * 判斷複選框有無選中  
  3.  * 如果有選中則返回true 否則返回false  
  4.  * @param name  
  5.  * @return  
  6.  */  
  7. function checkSelect(name){   
  8.     var checkboxs = document.getElementsByName(name);   
  9.     for(var i=0;i<checkboxs.length;i+=1){   
  10.         if(checkboxs[i].checked == true ){   
  11.             return true ;   
  12.         }   
  13.     }   
  14.     return false ;   
  15. }  
/** * 判斷複選框有無選中 * 如果有選中則返回true 否則返回false * @param name * @return */function checkSelect(name){var checkboxs = document.getElementsByName(name);for(var i=0;i<checkboxs.length;i+=1){if(checkboxs[i].checked == true ){return true ;}}return false ;}

 

 

 

Js代碼 {
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
function onclick()
{
dp.sh.Toolbar.CopyToClipboard(this);return false;
}
}
}
}
}
}" href="http://writeblog.csdn.net/#">
  1. /**  
  2.  * 按照yyy-MM-dd來格式化日期  
  3.  * @param d 需要格式化的日期  
  4.  */  
  5. function formatDate(d){   
  6.     var mon=d.getMonth()+1;   
  7.     var year=d.getFullYear();   
  8.     var date=d.getDate();   
  9.     return year+"-"+(mon<10?"0"+mon:mon)+"-"+(date<10?"0"+date:date) ;   
  10. }  

 

^/d{1,}.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.