JQuery Basic Syntax

jquery(html to select).action(parameters …)

or

$(html to select).action(parameters …)

note that some actions e.g. next() result in a selection; others e.g. length() return a result.

Most will be written rooted in the $(document).ready( function() {…}), to ensure the DOM is fully created when the code executes.

This can be shortened to: $(function() {…})

It is sometimes useful to chain multiple actions on the same selection e.g.

$(html to select).action(parameters …).action(parameters …)

Note – they will occur sequentially and in order.

Leave a Reply