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/# ">
- /**
- * String trim method
- * @ 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;
- }
/*** 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/# ">
- /**
- * Select all or not all
- * @ Param mark indicates whether to select all or reverse.
- * @ Param name: name of the HTML Element
- * @ 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;
- }
- }
- }
/*** 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/# ">
- /**
- * Check whether the check box is selected.
- * If selected, true is returned. Otherwise, false is returned.
- * @ 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;
- }
/*** 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/# ">
- /**
- * Format the date according to yyy-MM-dd.
- * @ Param d the date to be formatted
- */
- Function formatDate (d ){
- Var mon = d. getMonth () + 1;
- Var year = d. getFullYear ();
- Var date = d. getDate ();
- Return year + "-" + (mon <10? "0" + mon: mon) + "-" + (date <10? "0" + date: date );
- }
^/D {1 ,}.