In-depth analysis of the enumeration function in JavaScript

Source: Internet
Author: User

Because Microsoft AJAX Library has greatly expanded JavaScript,

Enumeration is also a common function,

This is to explore the JavaScript enumeration function.

Because the example is simple,

So it's okay to directly look at the HTML Tag.
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Asp: ScriptManager ID = "ScriptManager1" runat = "server">
</Asp: ScriptManager>

<Script language = "javascript" type = "text/javascript">
Type. registerNamespace ("BaoBeiMe ");
// Register an enumeration
BaoBeiMe. EnumDepartment = function (){

}
BaoBeiMe. EnumDepartment. prototype = {
One: "Information Department ",
Two: "Business Department ",
Three: "Finance Department ",
Four: "R & D department"
}
BaoBeiMe. EnumDepartment. registerEnum ("BaoBeiMe. EnumDepartment ");

Function Button1_onclick (){
Var enumDepartment = new BaoBeiMe. EnumDepartment ();
Var lblMsg = $ get ('<% = lblMsg. ClientID %> ');
LblMsg. innerText = "One is" + enumDepartment. One + "," +
"Two is" + enumDepartment. Two + "," +
"Three is" + enumDepartment. Three + "," +
"Four is" + enumDepartment. Four + "";
}

</Script>

<Div>
<Input id = "Button1" type = "button" value = "retrieve the enumerated value"

Onclick = "return Button1_onclick ()"/> <br/>
<Br/>
<Asp: Label ID = "lblMsg" runat = "server" Text = ""> </asp: Label>
</Div>
</Form>
</Body>
</Html>

Result

Related Article

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.