Summary of common JavaScript methods

Source: Internet
Author: User
Summary of common javascript methods

 

Js Code {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Dp. sh. Toolbar. CopyToClipboard (this); return false;
}
}
}
}
}
} "Href =" http://writeblog.csdn.net/# ">
  1. /**
  2. * String trim method
  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 method of the String * @ 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 Code {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Dp. sh. Toolbar. CopyToClipboard (this); return false;
}
}
}
}
}
} "Href =" http://writeblog.csdn.net/# ">
  1. /**
  2. * Select all or not all
  3. * @ Param mark indicates whether to select all or reverse.
  4. * @ Param name: name of the HTML Element
  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. }
/*** Select all or deselect function * @ param mark indicates whether to select all or deselect * @ param name corresponding to the HTML element 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 Code {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
DP. Sh. toolbar. copytoclipboard (this); Return false;
}
}
}
}
}
} "Href =" http://writeblog.csdn.net/# ">
  1. /**
  2. * Check whether the check box is selected.
  3. * If selected, true is returned. Otherwise, false is returned.
  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. }
/*** Check whether the check box is selected * true if selected; otherwise 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 Code {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
DP. Sh. toolbar. copytoclipboard (this); Return false;
}
}
}
}
}
} "Href =" http://writeblog.csdn.net/# ">
  1. /**
  2. * Format the date according to yyy-MM-dd.
  3. * @ Param d the date to be formatted
  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 ,}.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.