Interview :: JQuery
CDN stands for Content Delivery Network or Content Distribution Network. It is a large distributed system of servers deployed in multiple data centers across the internet. It provides the files from servers at a higher bandwidth that leads to faster loading time. These are several companies that provide free public CDNs:
- Microsoft
- Yahoo
The primary goal of the CDN is to provide content to the end-users with high availability and high performance.
Advantages of using CDN:
- It reduces the load from the server.
- It saves bandwidth. jQuery framework is loaded faster from these CDN.
- If a user regularly visits a site which is using jQuery framework from any of these CDN, it will be cached.
You can use a jQuery library in the ASP.Net project from downloading the latest jQuery library from jQuery.com and include the references to the jQuery library file in your HTML/PHP/JSP/Aspx page.
If you want to work with an element on the web page, first you need to find it. Selectors find the HTML elements in jQuery. There are many types of selectors. Some basic selectors are:
- Name: It is used to select all elements which match with the given element Name.
- #ID: It is used to select a single element which matches with the given ID
- .Class: It is used to select all elements which match with the given Class.
- Universal (*): It is used to select all elements available in a DOM.
- Multiple Elements E, F, G: It is used to selects the combined results of all the specified selectors E, F or G.
- Attribute Selector: It is used to select elements based on its attribute value.
: jQuery filter is used to filter the specific values from the object. It filters the result of your original query into specific elements.
There are three types of selectors in jQuery:
- CSS Selector
- Custom Selector
- XPath Selector
ID selector and class selector are the same as they are in CSS. ID selector uses ID while class selector uses a class to select elements.
You use an ID selector to select just one element. If you want to select a group of elements, having the same CSS class, use class selector.
What is the use of serialize() method in JQuery?
The jQuery serialize() method is used to create a text string in standard URL-encoded notation. It serializes the form values so that its serialized values can be used in the URL query string while making an AJAX request.
Syntax:
For complete example:
The jQuery val() method is used:
- To get the current value of the first element in the set of matched elements.
- To set the value of every matched element.
Syntax:
For complete example: "You can use addclass() jQuery method to add CSS class to an element and removeclass() jQuery method to remove CSS class from an element.