Wednesday, December 11, 2019

Helloworld - My Get-Go Jquery Program

What is jQuery
jQuery is nix but JavaScript library that comes amongst rich functionalities. It's modest in addition to faster than many JavaScript code written yesteryear an average spider web developer. By using jQuery nosotros tin write less code in addition to do to a greater extent than things, its makes spider web developer's chore rattling easy. In elementary word, jQuery is a collection of several useful methods, which tin last used to attain many mutual tasks inward JavaScript. H5N1 twain of lines of jQuery code tin do things which demand likewise many JavaScript lines to accomplish. The truthful ability of jQuery comes from it's CSS-like selector, which allows it to pick out whatever chemical element from DOM in addition to modify, update or manipulate it. You tin utilisation jQuery to do cool animations similar fade inward or fade out. You tin also alter CSS degree of a constituent dynamically e.g. making a constituent active or inactive. I accept used this technique to implement tabbed UI inward HTML. I tin vouch for jQuery that in 1 lawsuit you lot start using it, you lot volition never become dorsum to plainly erstwhile JavaScript, it's clear, concise in addition to powerful. You volition fifty-fifty regret why you lot are non using jQuery before.


What nosotros tin grip using jQuery

jQuery is rattling powerful, it provides methods in addition to API to do almost all kinds of affair you lot tin do amongst JavaScript. Though jQuery is specially practiced inward the next area
  •    HTML in addition to DOM manipulation
  •    CSS manipulation
  •    HTML resultant methods
  •    AJAX
  •    Utilities

By using jQuery you lot tin add together a novel chemical element into DOM, update existing chemical element from DOM in addition to tin easily take whatever element. jQuery's powerful degree in addition to id selector allow you lot to pick out whatever HTML chemical element or grouping of elements for selective manipulation. jQuery also allows you lot to pick out in addition to modify attributes from whatever HTML chemical element inward DOM.




How to Use jQuery

If you lot desire to utilisation jQuery, you lot merely demand to acquire jQuery file e.g jquery-1.2.6.min.js or latest version from its official site or whatever of iii pop CDN URL which provides jQuery download. For example <script type="text/JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script> downloads jQuery from Google's content delivery network. You tin even ship jQuery library along amongst your app yesteryear saving downloaded file to your file-system location.

When nosotros desire to utilisation this nosotros accept to include this file to our programme file(i.e HTML file). For illustration this illustration loads jQuery from local drive rather than downloading it from internet. By the way, at that spot are about advantages of downloading jQuery using CDN networks. CDN stands for content delivery network. Some fourth dimension spider web developer also confuses where to position the script tag e.g. should nosotros position script tag on caput or body.

Well you lot tin position it anywhere but putting it on trunk brand to a greater extent than feel on functioning perspective, because inward that instance jQuery library volition last downloaded later on all HTML, CSS, Images are downloaded in addition to page is rendered. Even if it stuck downloading jQuery from meshing you lot volition non run across the blank page, which is the instance when you lot position script tag on head.

By the way, this consideration volition solely occur, if you lot determine to download jQuery from meshing rather than from local drive, in addition to if you lot the 1 who similar to run across all JavaScript dependency at the top of the page, hence position it inward head. I similar to position jQuery download code, correct at the top section, on head.


Simple jQuery  Example

Here is our start jQuery program, which does the actually elementary thing. There is a button, you lot merely demand to click it in addition to all of a precipitous you lot run across a welcome message on your screen. This is a practiced illustration of how you lot tin acquire a DOM chemical element in addition to add together novel HTML code there. In adjacent section, you lot volition run across a total explanation of this jQuery program.

<html>     <head>         <title>My First jQuery Program</title>         <meta charset="UTF-8">         <meta name="viewport" content="width=device-width">         <script type="text/JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script>     </head>     <body>         <script type="text/javascript">             $(document).ready(function() {                 $("button").click(function() {                     $("#bClick").html("<h1>Hurry!!! </h1><h2>Welcome to wonderful basis of jQuery</h2>");                 });              });         </script>         Click the push to run across exhibit         <button>Click me</button>         <div id="bClick"></div>     </body> </html>

in addition to hither is the output, or how does it await similar inward your browser e.g. meshing explorer, chrome or Firefox :
 jQuery is nix but JavaScript library that comes amongst rich functionalities HelloWorld - My First jQuery Program

Explanation of code:

jQuery syntax is made for selecting HTML elements in addition to performing about activity on the element(s). Basic syntax is: $(selector).action(), here $ sign is short-cut of jQuery() method in addition to used to define/access jQuery.  (selector) is used to "query (or find)" HTML elements, in addition to tin last whatever CSS mode selector or special jQuery selectors.  jQuery action() is the chore to last performed on the selected element(s). For example, inward our program, nosotros accept  $(document).ready(function() { ...});  which is where your all jQuery code should go. This method is executed in 1 lawsuit browser finished loading HTML page in addition to DOM is ready to last accessed. $("button") is used to acquire all HTML push chemical element since at that spot is solely 1 here, nosotros volition acquire a reference of that. click() is used to heed to click event, in addition to it registers listener the anonymous business office you lot passed to it. The code hither is executed when push is clicked. If you lot await our code, you lot volition run across that nosotros are in 1 lawsuit again getting reference of an HTML chemical element whose id is bClick, $("#bClick") returns a DIV amongst id bClick, # is used to announce ID, in addition to this type of selector is known every bit ID selector. Once you lot acquire this element, you lot laid it's HTML yesteryear passing the HTML text to it, which is what displayed when you lot click the button.


Good for a start jQuery program, I am certain the to a greater extent than you lot do, the to a greater extent than started loving it. If you lot desire to start serious evolution inward jQuery, I propose to become through this list of about practiced jQuery books in addition to uncovering 1 you lot like. It makes feel for all front-end spider web developers to at-least know jQuery. By the way, JavaScript is getting tons of practiced library, which is driving a lot of practiced development. H5N1 twain of other useful JavaScript library are Angular.js in addition to Node.js, I am certain you lot heard well-nigh them every bit well. Comparing to jQuery at that spot all the same inward the early on state, on the other hand, jQuery has almost captured all JavaScript front-end market.

Further Reading
The Complete jQuery Course: From Beginner To Advanced!
Up in addition to Running amongst jQuery
jQuery Fundamentals By Dan Wahlin

No comments:

Post a Comment