jQuery

Add jQuery to Your Web Pages

  • Download jQuery

    This component was made by Stratis Dermanoutsos. The code can be found here.

    Use by including the ‘jquery-<version>.min.js’ file inside the <head> element.

    <head>
      <script src="jquery-<version>.min.js"></script>
    </head>
    
  • jQuery CDN

    <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/<version>/jquery.min.js"></script>
    </head>
    

Basic syntax

This component was made by Stratis Dermanoutsos. The code can be found here.

For example,

This component was made by Stratis Dermanoutsos. The code can be found here.

Selectors

They work quite like CSS.

  • <p> elements

    $("p")
    
  • element with id=“test” (’ # ’)

    $("#test")
    
  • elements with class=“test” (’ . ‘)

    $(".test")
    

Events

Mouse EventsKeyboard EventsForm EventsDocument/Window Events
clickkeypresssubmitload
dblclickkeydownchangeresize
mouseenterkeyupfocusscroll
mouseleaveblurunload

For example, do something when any paragraph (<p>) elementh is clicked

This component was made by Stratis Dermanoutsos. The code can be found here.

Resources