jQuery Examples

please click here for more wordpress cource

Sure! Here are some examples of jQuery code:

  1. Hiding and Showing Elements
  // Hide element with ID "myElement"
  // Show element with ID "myElement" after 3 seconds
  }, 3000);

Adding and Removing Classes

  // Add class "active" to element with ID "myElement"
  // Remove class "active" from element with ID "myElement" after 2 seconds
  }, 2000);

Animating Elements

  // Animate the element with ID "myElement" to move left 100px over 1 second
  $("#myElement").animate({left: '100px'}, 1000);

Event Handling

  // When element with ID "myButton" is clicked, show an alert message
    alert("Button clicked!");

Ajax Requests

  // Make an Ajax request to get data from a remote server
    url: "http://example.com/data.json",
    type: "GET",
    dataType: "json",
    success: function(data){
      // Do something with the data

I hope these examples are helpful!

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *