Jquery
what is Jquery
-
JavaScript library designed to simplify the client-side scripting of HTML
- free
- open source
Jquery Selectors
- $("#idElement): elements with the specified id
- $(".className): element with the specified className
- $("#idElement .className)
- $("[attribute='value']")
- $(":first-child")
You can combine these selector in many various ways.
DOM ManipulatinG
- element.addClass()
- element.removeClass()
- element.attr("attributeName")
- element.attr("attributeName", "attributeValue")
- element.html()
- element.html(htmlString)
- element.empty()
- element.hide()
- element.show()
Dom Events
-
element.click( handler(eventObject) );
$("#idElement").click(function(event) {
alert("click");
});
Ajax
- asynchronous web applications
- Jquery has a full suite of AJAX capabilities
var request = $.ajax( "example.html" ) .done(function() { alert("success"); }) .fail(function() { alert("error"); }) .always(function() { alert("complete"); });
JSON
-
JavaScript Object Notation
-
like Javascript Objects
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
LAB
Let's play with some examples
Jquery
By Bogdan Posa
Jquery
- 989