JQuery Basics Notes
JQuery Basics Notes
- Simplifies HTML document traversal and manipulation, event handling, animation, and Ajax.
- Syntax: $(selector).action()
Advantages of jQuery:
- Cross-browser compatibility.
Usage Example:
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
3. Callback Functions
- Example:
$("#btn").click(function(){
$("p").hide("slow", function(){
});
});
4. jQuery Selectors
Examples:
Advanced Selectors:
Common Methods:
Example:
$("button").click(function(){
$("#demo").text("Hello jQuery!");
});
6. jQuery Events
Example:
$("p").click(function(){
$(this).hide();
});
7. jQuery Effects
Visual Effects:
- Animation: .animate()
Example:
$("#btn").click(function(){
$("#box").fadeOut(1000);
});
What is AJAX?
$("#btn").click(function(){
$("#div1").load("demo_test.txt");
});
$.ajax({
url: "demo_test.txt",
success: function(result){
$("#div1").html(result);
});