JS commonly used in the output mode (five) _javascript skills

Source: Internet
Author: User

Not much nonsense, directly to the people to work, the specific details as follows:

1, alert ("Content to be exported");

-> a dialog box in the browser and then displays what you want to output

->alert converts the content to be output first to a string and then to the output

2, document.write ("content to be exported");

-> directly in the page to show the content of the output

3, Console.log ("content to be exported");

-> Output in console

4, Value-> to text box (form Element) assignment content

-> get the contents of a text box (form Element)

document.getElementById ("Search"). Value = "What to add to #search this text box";

5, Innerhtml/innertext-> to the form element in addition to the label assignment content

document.getElementById ("Div1"). InnerHTML = "Come on, let's Go!"
document.getElementById ("Div1"). innertext = "Come on, let's Go!"

The difference between->innerhtml and innertext

1 innerHTML when the value of the assignment, if you encounter a valid HTML tag will treat it as a real label processing, the label can play their role;

InnerText whether or not the label as text to assign value, then see is the text, the label does not play its role;

(innerHTML can recognize HTML tags when assigned, and innertext cannot recognize them)

2 in some Firefox browsers, InnerText is not supported, and innerHTML is supported by all browsers

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.