jQuery
JavaScript library that simplifies DOM manipulation and AJAX calls
Lessons
- What is jQuery?
- Element Selection
- Event Handling
- Changing Content
- CSS Manipulation
- Show/Hide Elements
- Working with Forms
- AJAX Requests
- Adding Elements to the DOM
- Animations
What is jQuery?
jQuery is a fast JavaScript library that simplifies HTML document handling, event binding, and AJAX.
Example:
<script>
$(document).ready(function() {
alert('Page is ready!');
});
</script>
Example Description:
Element Selection
Use $() to select and manipulate HTML elements.
Example:
$('#myDiv').hide();
Example Description:
Event Handling
jQuery simplifies handling user actions like clicks.
Example:
$('button').click(function() { alert('Button clicked!'); });
Example Description:
Changing Content
jQuery allows easy content updates.
Example:
$('#message').text('New message!');
Example Description:
CSS Manipulation
You can change styles directly.
Example:
$('p').css('color', 'red');
Example Description:
Show/Hide Elements
jQuery supports hiding/showing elements with effects.
Example:
$('#box').fadeOut();
Example Description:
Working with Forms
You can easily retrieve input values
Example:
let name = $('#nameInput').val();
Example Description:
AJAX Requests
Fetch data from a server without reloading the page.
Example:
$.get('/api/user', function(data) { console.log(data); });
Example Description:
Adding Elements to the DOM
You can dynamically add elements to the page
Example:
$('#list').append('<li>New item</li>');
Example Description:
Animations
jQuery provides simple built-in animations.
Example:
$('#box').slideToggle();
Example Description: