What is JQuery?

158 Views

What is JQuery?

jQuery: 

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

 

now a day many of the biggest companies on the Web use jQuery, such as:

 

DOM Traversal and Manipulation

Let's get a button and change it's HTML to "Continue"

  $( "button" ).html( "Continue" )

 

Event Handling

 Let's show a image "#banner" which is hidden with display:none in its CSS when a button "#show" is clicked.

 $( "#show" ).onclick(function() {
        $("#banner").show();
    }); 

 

Animations

let's move a div having css property "background:red;height:100px;width:100px;position:absolute;" to 500px left on a button click.

 $(document).ready(function(){
  $("button").click(function(){
    $("div").animate({left: '500px'});
  });
});

 

Ajax

Save some data to the server and notify the user once it's complete.

 $.ajax({
  method: "POST",
  url: "demo.php",
  data: { name: "Roshan", location: "Ranchi" }
})
  .done(function( msg ) {
    alert( "Data Saved: " + msg );
  });