JavaScript basic Getting Started syntax collection 1th/3 Page _ Basics

Source: Internet
Author: User
Create a script block
<script language= "JavaScript" >
JavaScript Code goes here
</script>
Hide Script code

<script language= "JavaScript" >
<!--
document.write ("Hello");
-->
</script>

Display when the browser is not supported

<noscript>
Hello to the Non-javascript browser.
</noscript>

Linking external script files

<script language= "JavaScript" src= "/" Youname.js "></script>

Comment Script

This is a comment
document.write ("Hello"); This is a comment
/*
All of this
is a comment
*/

Output to Browser

document.write ("<strong> output Content </strong>");

Defining variables

var myvariable = "some value";

string addition

var myString = "String1" + "String2";

String search

<script language= "JavaScript" >
<!--
var myvariable = "Hello There";
var thereplace = Myvariable.search ("there");
document.write (Thereplace);
-->
</script>

String substitution

Thisvar.replace ("Monday", "Friday");
Current 1/3 page 123 Next read the full text

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.