please click here for more wordpress cource
Sure! Here are some examples of jQuery code:
- Hiding and Showing Elements
$(document).ready(function(){
// Hide element with ID "myElement"
$("#myElement").hide();
// Show element with ID "myElement" after 3 seconds
setTimeout(function(){
$("#myElement").show();
}, 3000);
});
Adding and Removing Classes
$(document).ready(function(){
// Add class "active" to element with ID "myElement"
$("#myElement").addClass("active");
// Remove class "active" from element with ID "myElement" after 2 seconds
setTimeout(function(){
$("#myElement").removeClass("active");
}, 2000);
});
Animating Elements
$(document).ready(function(){
// Animate the element with ID "myElement" to move left 100px over 1 second
$("#myElement").animate({left: '100px'}, 1000);
});
Event Handling
$(document).ready(function(){
// When element with ID "myButton" is clicked, show an alert message
$("#myButton").click(function(){
alert("Button clicked!");
});
});
Ajax Requests
$(document).ready(function(){
// Make an Ajax request to get data from a remote server
$.ajax({
url: "http://example.com/data.json",
type: "GET",
dataType: "json",
success: function(data){
// Do something with the data
}
});
});
I hope these examples are helpful!