Article

Introduction to functions

https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard

Functions are names that stand for multiple lines of code.

These names can be used multiple times once defined.

A simple function used to raise an alert to the browser may be written like so: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/functions/ex1.js?actionable=false

The name of the function is make_alert. It uses the JavaScript command alert(), to prompt a browser show the message hello. The make_alert function can be used by 'calling' it. The code for calling it can be written as so: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/functions/ex2.js?actionable=true

<script>
$(document).ready(function(){
  XT1
});
</script>
Copy to clipboard
Send to Live Demo

Live demo

<script>    
$(document).ready(function() {
  XT1
});
</script>
<script>
  
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Your browser is too small

Resize your browser to be at least 769px wide.