Data types in JS (see jquery Combat < Appendices >)

Source: Internet
Author: User

Constants of all data types are treated as objects.
(a), JS comes with the data type how to create an object?
The values of the base type number, String, 23, "ABC", and so on are themselves objects.
Date Type: Creates an object from a constructor, new date (2015,7,8)
(b), how do users create custom objects?
1. through var o = new Object ();
Then dynamically specify the properties of the object o.
2. Through the object literal;
3. By defining a constructor function.

Second, the characteristics of JS custom object
Object contains properties,
property contains property names and property values,
The property name is a string, and the property value can be any object.

Creating a custom JS object is more like defining a temporary language and using some strings to correspond to a constant (including functions).
JS a function is a constant, and 1, "ABC" these basic data no difference.

Third, JS callback function

A callback is a function so is passed as an argument to another function and are executed after it parent function has C ompleted.

<HTML>      <Head>      <title>callback function (callback)</title>   <Scriptlanguage= "JavaScript"type= "Text/javascript">   functionA (callback) {alert ("I am the parent function A! "); Alert ("Call callback function");   Callback (); }   functionB () {Alert ("I'm the callback function, B ."); }   functionC () {Alert ("I'm the callback function C ."); }     functionTest () {a (b);   A (c); }     </Script>   </Head>      <Body>   <H1>Learn JS callback function</H1>   <ButtonOnClick=test ()>Click Me</Button>   <P>Should be able to see that two callback functions were called</P>   </Body>      </HTML>

Four, closed package
JS, procedural programming, allows the use of intrinsic functions to be defined in an external function. Object programming generally does not allow another function to be defined in one function.
It also means that there is an object-type programming phenomenon in procedural programming: the intrinsic function may be longer than the life cycle of an external function.
What is a closure package?
The concept of closures is for procedural programming.
That is, an intrinsic function references a local variable defined by an external function, and after the execution of the external function, the intrinsic function can still use the referenced external variables, that is, the life cycle of these variables exceeds the life cycle of the external function that defines it, and the closure of the inner function is formed.


Five, the selector:
(i), determine the level of the DOM to which the element belongs
$ ("*"): all elements
$ ("#id"): Select by ID
$ (". Class"): Depending on the class to which it belongs
$ ("P"): Based on element name
$ ("Body>div"): As a <body> direct sub-node <div>
$ ("Body>div:has (A)"): <div> as a direct child node of <body>, <div> containing links (<a>).
(b) Screening of selected similar elements

1. Based on the position in the same element
$ ("P:first"):
$ ("Tr:even")
$ ("UL Li:eq (3)")
$ ("UL li:gt (3)")

2. Depending on the attributes of the element
$ ("[href]"): all elements with href attribute
$ ("[href= ' # ']"): The value of all href attributes equals "#" elements
$ ("[href!= ' # ']"): The value of all HREF attributes is not equal to the "#" element
$ ("[href$=. jpg]"): The value of all HREF attributes contains elements ending with ". jpg"


$ (": Contains (' W3school ')"): element containing the specified string
$ (": Empty"): all elements with No child (element) node
$ ("P:hidden"): All hidden <p> elements
$ ("table:visible"): All visible tables

Selector for manipulating input elements
$ (": Input"): all <input> elements
$ (": Text"): All type= "text" <input> elements
$ (":p assword"): All <input> elements of type= "password"

$ (": Enabled"): All active input elements
$ (":d isabled"): all disabled input elements
$ (": Selected"): All selected input elements
$ (": Checked"): All selected input elements

(iii), other options
$ (": Header") all heading elements $ (": Animated") all animated elements

Data types in JS (see jquery Combat < Appendices >)

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.