JQuery is one of the most powerful JavaScript libraries and remains open source project.
It represents “write less and do more” and also support all modern browsers includes Internet Explorer, Google chrome, opera, FileFox and Safari
In MVC 4 application JQuery scripts are added by default in “Scripts” folder
In this session let’s discuss about the Jquery at high level, because it is important for the MVC application development
JQuery Selector:
$("#header") | Find the element with an id of ˝header˝ |
$(".editor-label") | Find all elements with a class name of ˝.editor-label˝ |
$("div") | Find all <div> elements |
$("#header div") | Find all <div> elements that are descendants of the element with an id of ˝header˝ |
$("#header > div") | Find all <div> elements that are children of the element with an id of ˝header˝ |
$("a:even") | Find evenly numbered anchor tags |
JQuery and Ajax
Jquey includes everything need to send asynchronous requests back to the servers.
- It can generate POST and Get request
- It will notify you when the request is completed
- It can send and receive XML data and also support HTML, text and JSON(Javascript object Notation) format
Unobstrusive JavaScript – it is practice of keeping javascript code separated from markup and all the script code you need is placed inside the “.js” files.