- You can use JavaScript to add elements, attributes, and text to the page, or remove them
You can specify a set of steps for the browser to follow (like a recipe), which allows it to access or change the content of a page. For example:
when a specific event has occurred. For example, it could be run when:
- A button is pressed
- A link is clicked (or tapped) on
- A cursor hovers over an element
- Information is added to a form
- An interval of time has passed
- A web page has finished loading
Modify the content of the page Program rules or instructions the browser can follow React to events triggered by the user or browser
-
SLIDESHOWS
-
FORMS
-
RELOAD PART OF PAGE
-
FILTERING DATA
- . The script is triggered when the button is clicked.
- It collects the name entered into the form field.
- It checks that the user has entered a value.
- If the user has not entered anything, a message will appear telling them to enter a name.
- If a name has been entered, calculate the cost of the sign by multiplying the number of letters by the cost per letter.
- Show how much the plaque costs.
- A script is a series of instructions that the computer can follow in order to achieve a goal. Each time the script runs, it might only use a subset of all the instructions.
- Computers approach tasks in a different way than humans, so your instructions must let the computer solve the task prggrammatically.
- To approach writing a script, break down your goal into a series of tasks and then work out each step needed to complete that task (a flowchart can help).
there are two types of expressions.
VALUE TO A VARIABLE
MORE VALUES TO RETURN A SINGLE VALUE
create a single value from one or more values.
operators, which you can use with numbers. You may remember some from math class.
It is used to join the strings on either side of it.
specific task. If different parts of a script repeat the same task, you can reuse the function (rather than repeating the same set of statements).