javaScript (excluding jquery)
1: search by id;
X = document. getElementById ("demo") // query by id is unique, and x represents a unique element.
2: search by name:
X = document. getElementsByName ("myInput"); // here, the ments indicates that it returns a set, because the name attribute can be repeatedly defined as X [0]. innerHTML = "Hello JavaScript"; // specify the first few because it is an array. Even if there is only one, it must be written to zero.
3: search by element name:
Var x = doc
Differences between the js for in loop and the foreach loop in java, jsforeach
This article analyzes the differences between the js for in loop and the foreach loop in java. Share it with you for your reference. The specific analysis is as follows:
The for in loop in js is defined as follows:Copy codeThe Code is as follows: for (var variable in obj ){...}
Obj can be a common js object or an array. If obj is a js object, variable obtains the property name of the object in the traversal, rather th
met, execute the for loop again according to the preceding process. If the conditions are not met, end the for loop.
The for loop can also be used for nesting to implement complex operations. The nested for loop is used for Bubble sorting. The following are two examples of for loop nesting.
Print right triangle,
for (var i = 1; i
Print 99 multiplication table
for (var i = 1; i
For in Loop
For-in is used to traverse the attributes of an array or object (cyclically operate the attributes of an
became the "Focus" and "Triumph" of the audience. Our "Wei Zi" of "Jun Jie" lost all the "Chinese" children present and moved all the "son of the East". "Picasso" drew the "competition Contest" for us ", the antelope is happy to run for us, and the bluebird is happy to sing songs for us ". So you became the "Big Dipper" in my heart and the "beautiful Leopard" in my arms ". We are lucky to be honored by Changan Star ". At the awards ceremony, you put on a "crown" for me, and I put on a "Corolla"
)
"; $x =-345; Int ( -345) var_dump ($x); echo ""; $x = 0x11; Int (var_dump) ($x); echo ""; $x = 011; Int (9) var_dump ($x);? >
Floating point number
PHP floating point number is a decimal or exponential form of numbers
"; $x = 2.4e3;//float (2400) var_dump ($x); echo ""; $x = 8e-1;//float (0.8) Var_dump ($x);? >
Boolean type
PHP Boolean has only two values: TRUE or false (case insensitive), often used for conditional testing. When you output a Boolean type with the echo command, o
All things in JS are objects: strings, numbers, dates, and so on;In JS, the object is the data that owns the property and methodLocal JS variableA variable declared inside a JavaScript function (using VAR) is a local variable, so it can only be accessed inside the function. (The scope of the variable is local).You can use local variables with the same name in different functions, because only the function that declares the variable can recognize the variable.The local variable is deleted as soon
executed until the user responds.Seven It's mostly handy for your JavaScript. You can see what you're outputting in the page.His advantages compared to alert are:1. He can see the structure of things, if it is alert, fade out an object is [Object Object], but the console can see the contents of the object.2. Console does not interrupt the operation of your page, if you use alert to bounce out the content, then the page is dead, but the console output after your page can be normal operation.3. T
using it.2. The syntax of doubt:PHP stores all global variables in an array called $GLOBALS [index]. Index holds the name of the variable. This array can be accessed inside the function, or it can be used to update global variables directly.Not the same as expected: The running result is still 10,3.$cars =array ("Volvo", "BMW", "Toyota"); Array of different, string with "()"echo "My car is a {$cars [1]}"; Array, string with "{variable}"4. Integer typ
JS Data Type classificationBase data type: Number,string,boolean,undefined,nullComplex data type: Object,array,function,regexp,date,errorGlobal Data type: MathWe can use TypeOf to determine the type of a variable.But usually only 6 states are returned, respectively:Undefined not initializedBooleanStringNumberObject objects or NULLfunction functionsIf you want to determine specifically which type of object is, use theObject.prototype.toString.call ();Array Object1, the creation of the array1 var
point, or an exponential form.In the following example we will test for different numbers. The PHP var_dump () function returns the data type and value of the variable $x = 10.365; Var_dump ($x); Echo "$x = 2.4e3; Var_dump ($x); Echo "$x = 8E-5; Var_dump ($x);? >PHP Boolean typeThe Boolean type can be TRUE or FALSE.$x=true; $y=false;Boolean is commonly used for conditional judgment, more tutorials on conditional control.PHP arraysAn array can store multiple values in a variable.An array is crea
] = "Saab" mycars[1] = "Volvo" mycars[2] = "BMW" for (x in Mycars) {document.write (mycars [x] + "Built-in operator functions for arraysAdd a value at the end of an arrayvar arr=new Array (1,2,3,4,5), Var len=arr.push (7,9); Console.log (Len,arr);Add a value at the beginning of the arrayvar arr=new Array (1,2,3,4,5), Var len=arr.unshift (7,9); Console.log (Len,arr);Delete the value of an array pop deletes the last one Shift vs. Pop Delete the value l
There are two basic output statements in PHP, Echo and printWhat's the difference between these two things?echo can output one or more characters at a time:Echo "This is a", "string,", "used", "multiple", "parameter." ";Like this, there is no problem with the output.The result of the output is: This is a string that uses more than one parameterThen echo's output is not wrapped, and if you need to wrap it, you can add it later Echo "This is a", "string,", "used", "multiple", "parameter." You can
DOM element directly by ID, so~
So ah, local variables must be declared with Var, not only because the Var will become a global variable, but also because of IE, there may be such a very inexplicable error ....
var variable instance 1
The code is as follows
Copy Code
function Test () {VAR1 = 2;alert (VAR1);}Test ();alert (VAR1);This can be displayed as 2function Test () {var var1 = 2;alert (VAR1);}Test ();alert (VAR1);
No error is defined for the variabl
Var. This is for some programmers who write JavaScript code to be aware of
The local variable is deleted as soon as the function completes.
Global JavaScript Variables
Variables declared outside a function are global variables and can be accessed by all scripts and functions on the Web page.
The lifetime of a JavaScript variable
The lifetime of JavaScript variables begins when they are declared.Local variables are deleted after the function is run.Global variables are deleted after the pag
trees-women
Rugged landscapes and terrain-male
Food-Women
Clothes and shoes-female
Invention and electronics-male
Occupations → students, white-collar workers, ordinary workers, jobless, high-end business people, etc.
Age → Youth (18-30), middle-aged (30-45), middle age (45-60)
Region → South, north
To draw a relatively accurate consumer group.
3. Analyze the buyer's appeal and consider the selling point
A
enter the year of birth, 18 years old or above to browse. JS effect is very powerful.
Hipstersound
Wellstoried
Nadezhda
The circular navigation and the background is quite fusion, the whole is a kind of elegant tone.
Sonance-audition
Edilteco
Keeping New York on Track
Luxury resorts
A resort site that uses hand-painted style icons is really rare.
Interaction with Artificial
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.