Simple use of four JS Code and jquery Architecture

Source: Internet
Author: User

1: Get all attributes of srcelement

FunctionT ()
{
VaRSTR = "";
For(Mm in window. event. srcelement)
STR + = mm + "=" + window. event. srcelement [mm] + "\ n"; // obtain all attributes of srcelement
Alert(STR );
}

2: Dynamic Output

Function T1 ()
{
VaR myvariable = "Hello there ";
Document. Write ("out this words ");
Document. Write (myvariable. Italics () + "<br/> ");
Document. Write (myvariable. tolowercase () + "<br/> ");
}

3: Array

Function T2 ()
{
VaR myvariable = "A, E, C, D ,";
VaR c = myvariable. substring (0, myvariable. Length-1 );
VaR stringarry = C. Split (",");
VaR I = 0;
For (I; I <stringarry. length; I ++)
{
Alert (stringarry [I]);
}
}

4. Obtain webpage Parameters

Function T3 ()
{
VaR urlparts = Document. url. Split ("? ");
VaR parameterparts = urlparts [1]. Split ("&");
VaR I;
For (I = 0; I <parameterparts. length; I ++)
{
VaR pairparts = parameterparts [I]. Split ("= ");
VaR pairname = pairparts [0];
VaR pairvalue = pairparts [1];
Alert (pairvalue );
}
}

// ==========Simple JS application in jquery Architecture============

// Obtain parameters
VaR selectid = "<% = request. querystring [" memberid "] %> ";

// Check whether it is empty
Function checkeditdata ()
{
If ($ ("# <% = textbox1.clientid %>"). Val () = "")
{
Alert ("Enter the user name ");
$ ("# <% = Textbox1.clientid %>"). Focus ();
}

// Use checkboxAjaxDelete cyclically
Function delrolein ()
{
VaR S = $ ("intput [@ checked]", "# checkbox1 ");
If (S. length> 0)
{
VaR v = "";
S. Each (function () {v = V + this. Value + ","});
// Self-executed Ajax loop deletion method;
}
Else
{
Alert ("select the role to be called out ");
}
}

// Add attributes to a server-side control
Funciton Xiao ()
{
VaR tempvalue = "58 ";
$ ("# <% = Linkbutton1.clientid %>"). ATTR ("href". Window. Location. href. Split ("? ") [0] + "? Ogid = "+ tempvalue );
}

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.