Common statements for 48 javascript

Source: Internet
Author: User
Tags set time

1. document.write (""); Output statement

The comments in the 2.JS are//

3. Traditional HTML Document order is: document->html-> (head,body)

4. The DOM order in a browser window is: window-> (navigator,screen,history,location,document)

5. Get the name and value of the element in the form: document.getElementById ("ID of the element in the form"). Name (or value)

6. A lowercase capitalization JS:document.getElementById ("Output"). Value = document.getElementById ("input"). Value.touppercase ();

Value types in 7.JS: string,number,boolean,null,object,function

Conversion of character types in 8.JS to numeric: parseint (), parsefloat ()

The numbers in 9.JS are converted into character types: ( "" variable)

The length of the string in 10.JS is: (length)

The characters in 11.JS are connected to the word typeface.

The comparison operator in 12.JS has: = = equals,! = is not equal to, >=, < <=

Declaring variables in 13.JS using: var for declaration

Decision statement structure in 14.JS: if (condition) {}else{}health.hrbfc120.com

Loop structure in 15.JS: for ([Initial expression];[ Condition]; [Upadte expression]) {Inside loop}

16. The Circular abort command is: Break

Functions definition in 17.JS: function functionname ([parameter],...) {Statement[s]}

18. When multiple form forms appear in a file, you can use document.forms[0],document.forms[1] instead.

19. Window: Open Window window.open (), close a window: window.close (), window itself: Self

20. Settings for the window.status=: "character";

21. Popup Message: Window.alert ("character");

22. Popup Confirm Box: Window.confirm ();

23. Popup Input Prompt Box: window.prompt ();

24. Specify the location of the current display link: window.location.href= "URL"

25. Remove the number of all forms in the form: document.forms.length

26. Close the output stream of the document: Document.close ();

27. String Append connector: =

28. Create a document element: Document.createelement (), document.createTextNode ()

29. Method of getting elements: document.getElementById ()

30. Set the value of the members of all text types in the form to be null:

var form = Window.document.forms[0]

for (var i = 0; i

if (Form.elements.type = = "Text") {

Form.elements.value = "";

}

}

31. Check the button in JS to determine whether to select: Document.forms[0].checkthis.checked (Checked property represents whether to check return TRUE or FALSE)

32. Radio button Group (the name of the radio button must be the same): the length of the radio button group Document.forms[0].groupname.length

33. Radio button Group to determine whether or not to be selected is also used checked.

34. The value of the drop-down list box: Document.forms[0].selectname.options[n].value (n sometimes use the drop-down list box name plus. SelectedIndex to confirm the selected value)

35. Definition of the string: var myString = new String ("This is Lightsword");

36. Turn the string into uppercase: String.touppercase (); The string is converted to lowercase: string.tolowercase ();

37. Returns the position where string 2 appears in string 1: String1.indexof ("String2")!=-1 the description was not found.

38. Take a character at the specified position in the string: Stringa.charat (9);

39. Remove the substring that specifies the start and end point in the string: stringa.substring (2,6);

40. Mathematical function: Math.PI (return pi), Math.sqrt2 (return to root), Math.max (value1,value2) returns the most value in two digits, Math.pow (value1,10) return

Value1 10-Time Square, Math.Round (value1) rounding function, Math.floor (Math.random () * (n 1)) returns the number of random machines

41. Define date type variable: var today = new Date ();

42. Date Function List: Dateobj.gettime () Gets the time, dateobj.getyear () Gets the year, Dateobj.getfullyear () gets four digits of the year, Dateobj.getmonth () is

To the month, Dateobj.getdate () Gets the day, Dateobj.getday () Gets the date a few, dateobj.gethours () Gets the Hour, dateobj.getminutes () gets

Points, Dateobj.getseconds () Gets the seconds, Dateobj.settime (value) set time, Dateobj.setyear (Val) set year, Dateobj.setmonth (val) setting

Month, Dateobj.setdate (Val) Set day, Dateobj.setday (val) set days of the week, Dateobj.sethours set hours, Dateobj.setminutes (val) settings

Minutes, Dateobj.setseconds (val) Set seconds [Focus: This datetime starts from 0]

43.FRAME representation: [window.] Frames[n]. objfuncvarname,frames["FrameName"]. Objfuncvarname,framename.objfuncvarname

44.parent represents the Father object, top represents the topmost object rl.120hrb.com

45. Open the child window's parent window as: opener

46. Indicates the location currently belongs to: this

47. When invoking the JS function in the hyperlink: (JavaScript:) to start with the name of the Add function

48. Do not execute this JS in the old browser:

Common statements for 48 javascript

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.