Some finishing method js

JSON.stringify (obj); // JSON object obj into the character JSON
JSON.parse (str); // convert the string str JSON JSON object
form elements turn json objects
        var arry = $ ( "# form ") .serializeArray (); // serialized form
        var obj = {}; // allocate memory space
        for (var i = 0; i <arry.length; i ++) {// the data type "field name from the defined class = data "background will automatically match the data
            obj [ARRY [I] .name] = ARRY [I] .Value;
        }

Open the current page URL of the page: window.location.href = "url"

window.history.back () Back, window.history.forward () returns the next page, window.history.go (return to the first few pages, you can also use the url visited) 

To obtain the names and values ​​of the elements in the form: document.getElementById ( "id number of elements in the form") .name (or value)

When a plurality of files appear form the form may be used document.forms [0], document.forms [1] instead. 

Click on the hyperlink to jump <a href="#" onclick="location.href='b.html'"> Jump </a>  

window.location.reload () to refresh the current page.
parent.location.reload () to refresh the parent object (a frame)
opener.location.reload () to refresh the parent window object (for single open window)
top.location.reload ( ) refresh the top of the object (for multi-windowing)

js is converted into numerical character: parseInt (), parseFloat () 
takes a string length of the js are: (length) 
a lowercase turn uppercase js: document.getelementbyid ( "output") value = document.getelementbyid. ( "input") value.touppercase ()  .;

A confirmation box: var flag = window.confirm (msg)  ;
pop input prompt box: var name = window.prompt ( "Please enter your name", " default value")

Remove any number of forms in the form of: document.forms.length

window.history.back () Back, window.history.forward () returns the next page, window.history.go (return to the first few pages, you can also use the visited url) 
toLowerCase () method is used to string lowercase. Examples: STR = var "the Hello World!"; Str.toLowerCase STR = ();
String.toUpperCase () so that all uppercase characters. 
The parseInt (String [, the radix (binary behalf)]) cast into an integer. 
isNaN (numValue): test whether numeric. 

Guess you like

Origin blog.csdn.net/weixin_41796956/article/details/91951512