Learning JQuery-- Understanding the basics

in GEMS4 years ago

Hello Everyone!

In this post we are going through the basics of JQuery, how to use jQuary and what is jQuary. So jQuary is a JavaScript library that simplifies HTML document traversing , event handling, animating, and Ajaz interactions for rapid web development. jQuary save our time and reduce the line of code which help us and other to understand the code.

wss.png

To use JQuary we can either download the files and save it in our system. To download the JQuary visit this link.

image.png

Or we can use the cdn link just like the Hive cdn( we used hivejs cdn in our previous posts). The following is the cdn of jquery.
https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js

Let's start using the cdn link and try this on a HTML site but before starting we should take a look on the syntax of jquery
. Basic syntax is: $(selector).action()

  • $ sign to define/access jQuery
  • (selector) to "query (or find)" HTML elements
  • jQuery action() to be performed on the element(s)

Open the VS code and create a HTML file.

image.png

Now let's write a code that will take some text and then display it using the alert method.


    <head>
        
        <title>Jquery tutorial by pakgamer </title>
       
     
    </head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <body>
       
        <input id="text1" type="text"   placeholder="Write something here.." ><br>
        <input type="button" value="click to display " id="btn1" >
        
    </body>
  <script>
      $(document).ready(function(){
          $('#btn1').click(function(){
            let text = $('#text1').val();
            alert(text)
          })
        

      })
  </script>
</html>

image.png

Ok! Now let's write something to check it.

image.png

Now let's use the hide method.

image.png

What this piece of code will do is whenever someone clicks the button the text box should disappear. if we use JavaScript for this kind of task it will take more time and also increase the line of code which is not a thing.

image.png


This is just a very basic introduction to help you understand what jQuery is and how it works in this next post we will understand stuff like selectors. Now if you like the post please upvote and comment if you want to give me some advise
ntitled-1.png

Sort:  

Congratulations @pakgamer! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You received more than 2250 upvotes. Your next target is to reach 2500 upvotes.

You can view your badges on your board And compare to others on the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @hivebuzz:

Introducing HiveBuzz Shop - Offer gifts with your favorite badges
Support the HiveBuzz project. Vote for our proposal!