Getting Started with PHP (8) PHP interacts with JavaScript

Source: Internet
Author: User

JavaScript is a scripting language that can be embedded in HTML code that has a browser running, based on event and object driven.


JavaScript is powerful, and the main features of the Web page are the following:

    1. Validating forms

    2. Web effects


JavaScript is still a lot of content, here we simply introduce the following JavaScript syntax rules.


Data types for JavaScript

String type (single quote multi-quote) numeric (integer, floating-point) Boolean (True False) object

Null value (used to clear the contents of a variable a = null;) undefined (the variable has not been assigned a value)


The use of the keyword VAR for the declaration and assignment of JavaScript variables

var var_name = value;

It is recommended that you declare a variable before you use it to make it easier to troubleshoot errors.

In JavaScript, each statement ends with a semicolon.


JavaScript definition functions

function Func_name (parameter) {

return var;

}

Calling functions

Func_name (); /* Parentheses cannot be omitted */


How JavaScript is embedded in the script

1. Can be embedded directly into the HTML code

<script language= "javascript" >/*language attribute can be omitted by default is javascript*/

JavaScript statements;

</script>

<body> <script> alert ("I am ceo,you son of Bitch"); </script></body>


JavaScript functions usually trigger execution under the corresponding event.

<input type= "Submit" name= "Submit" value= "Check" onclick= "Check ();" >

2. Referencing JavaScript files

<script src= "JS file path" ></script>

You can do this by writing JavaScript code separately into a JavaScript file with JS as the suffix name

Referencing JavaScript files in this way requires attention:

Only JavaScript script code can be included in a JavaScript file and cannot contain <script></script> and HTML code

JavaScript code cannot be included in the <script></script> that references JavaScript scripts.

This article is from the "thick Product Thin Hair" blog, please make sure to keep this source http://joedlut.blog.51cto.com/6570198/1855505

Getting Started with PHP (8) PHP interacts with 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.