Book Image

Mastering JavaScript Promises

Book Image

Mastering JavaScript Promises

Overview of this book

Table of Contents (16 chapters)
Mastering JavaScript Promises
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

A sample example


Before we start the prime topic of this chapter, we need to understand how we draft files that can use jQuery query. This will give us a better understanding of the code level working and will make us skilled to use promises in jQuery.

Let's start with selectors.

Selectors

Selectors enable us to select and manipulate HTML. We can use them to find HTML elements that are based on their IDs: classes, types, attributes, values, and much more stuff. These selectors are just like selectors in CSS, but with the jQuery touch. Here touch is all the selectors start with the dollar sign, $, followed by round brackets and dot, as shown in the following code:

<!DOCTYPE html>
<html>
   <head>
      <title> Selector in action </title>
      <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
      <script>
         $(document).ready(function(){
             $("button").click(function(){
                 $("p").hide(); // this will...