jQuery Step By Step Tutorial for Beginners
Tags: tutorial, javascript, jquery
Published: 2022-02-21 13:45:34

<p class="paragraph"> Howdy Coders, </p><p class="paragraph"> In this post, we will learn some basic usage of jQuery in web development. </p><p class="paragraph"> In modern development, jQuery has become an essential&nbsp;thing.  </p><p class="paragraph"> It makes our developing work faster and it is also easy to learn. </p><p class="paragraph"> So Let’s Start. </p><p class="paragraph"> Pre-Requisites: </p><p class="paragraph"> -To Learn jQuery Required to have some basic knowledge&nbsp;of HTML and&nbsp;<a href="http://localhost/jigar/tutscoder/learn-javascript-from-scratch/">Javascript</a>. </p><h2>What Is jQuery?&nbsp;</h2><blockquote ><p>jQuery&nbsp;is a fast, small, and feature-rich JavaScript library. </p><cite></cite></blockquote><p class="paragraph"> It makes things like <b>HTML document traversal and manipulation, event handling, animation, and Ajax</b> much simpler with an easy-to-use API that works <b>across a multiple browsers</b>. </p><h2>Benefits of using jQuery:</h2><ul><li>jQuery makes your JavaScript code smaller, faster, and cross-browser support.</li><li>Using jQuery you can Handle events like Click, hover, change, keyup, etc… and perform some action on it.<br></li><li>jQuery allows you to make add animation to your page like fade in, fade out, slide in, slide out or you can make custom animation.<br></li><li>With jQuery you can also make Ajax request without refreshing your whole page.</li></ul><p class="paragraph"> And lot more….. </p><p class="paragraph"> Also Read, </p><ul><li><a href="https://www.tutscoder.com/post/jquery-most-usefull-functions-list">12 Most Helpful jQuery Methods and Functions</a></li><li><a href="https://www.tutscoder.com/post/jquery-selectors">8 Most useful Jquery Selectors - You Need To Know</a><br></li><li><a href="https://www.tutscoder.com/post/how-to-check-uncheck-checkbox-with-jquery">How to check-uncheck all checkbox With jQuery</a><br></li></ul><p class="paragraph"> In This example, we are going to some basic of Javascript Click event by making A button Enable/Disable by using Link.So Let’s begin: </p><h3>Step-1:</h3><p class="paragraph"> Create an HTML page with its basic structure as follow: </p><pre><code class="code-block">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;jQuery Step-by-step&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- Content Area--&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre><h3>Step-2:</h3><p class="paragraph"> Add the element to perform some action on it.we’re going to add two links&nbsp;for enabling and disabling and one button.Add the following code inside the Body tag: </p><pre><code class="code-block">&lt;a href="#" id="next"&gt;Disable&lt;/a&gt;
&lt;button&gt;Register&lt;/button&gt;
&lt;a href="#" id="prev"&gt;Enable&lt;/a&gt;</code></pre><h3>Step-3:</h3><p class="paragraph"> Now we are going to add Jquery Libray. </p><p class="paragraph"> You can add Jquery by Downloading From official site&nbsp;<a href="http://jquery.com/">Jquery.com</a>. </p><p class="paragraph"> But in This example we are going to use Google’s copy of Jquery. </p><p class="paragraph"> Add The Following Code Below the Body tag: </p><pre><code class="code-block">&lt;script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js”&gt;&lt;/script&gt;</code></pre><h3>Step-4:</h3><p class="paragraph"> Add jQuery Script Below it. </p><p class="paragraph"> In following code we are using link id ‘next’ and ‘prev’ to perform task. </p><pre><code class="code-block">&lt;script type="text/javascript"&gt;
$("#next").click(function(){
    $(this).next().attr('disabled',true);
});

$("#prev").click(function(){
    $(this).prev().removeAttr('disabled');
});
&lt;/script&gt;</code></pre><p class="paragraph"> <b>Complete Code:</b>&nbsp;Here is the Complete code&nbsp;achieve from the above steps. </p><pre><code class="code-block">&lt;html&gt;
&lt;head&gt;&lt;/head&gt;
&lt;body&gt;
&lt;a href="#" id="next"&gt;Disable&lt;/a&gt;
&lt;button&gt;Register&lt;/button&gt;
&lt;a href="#" id="prev"&gt;Enable&lt;/a&gt;
&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$("#next").click(function(){
    $(this).next().attr('disabled',true);
});

$("#prev").click(function(){
    $(this).prev().removeAttr('disabled');
});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre><p class="paragraph"> <b>Conclusion:</b> </p><p class="paragraph"> So, These are some basic uses of Jquery. Thanks for reading. </p><p class="paragraph"> Do let me know If you face any difficulties please feel free to comment below we love to help you. if you have any feedback suggestions then please inform us by commenting. </p><p class="paragraph"> Don’t forget to share this tutorial with your friends on <a href="https://www.facebook.com/TutsCoder" target="_blank">Facebook</a>, and <a href="https://twitter.com/tutscoder" target="_blank">Twitter</a> </p>