JQuery Basic Interview Questions Part-2



How is body onload() function is defferent from document.ready() functon used in Jquery?
Document.ready() function is different from body onload() function because off 2 reasons.

1. We can have more than one document.ready() function in a page where we can have only one onload function.
2. Document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.

What is Jquery UI?
JQuery UI is a library which is built on top of JQuery library. JQuery UI comes with cool widgets, effects and interaction mechanism.

See below page on this site. Date Picker control used in this page to select date is an example of JQuery UI.

Name some of the methods of Jquery used to provide effects?
Some of the common methods are :

1. Show()
2. Hide()
3. Toggle()
4. FadeIn()
5. FadeOut()

what are the different type of selectors in Jquery?
There are 3 types of selectors in Jquery
1. CSS Selector
2. XPath Selector
3. Custom Selector

 How can you select all elements in a page using Jquery?
<script language="javascript" type="text/javascript">
$("*").css("border", "2px dotted red");
</script>

How can you select all elements in a page using jQuery?


To select all elements in a page, we can use all selectors, for that we need to use *(asterisk symbol).

<script language="javascript" type="text/javascript">
$("*").css("border", "2px dotted red");
</script>

The above code will select all elements of the web page and apply border width as 2 pixel, style as dotted and color as red.

What is the Difference between Jquery-X.X.X.js and Jquery.X.X.X-min.js?
In terms of functionality, there is no difference between the jQuery-x.x.x.js and jQuery-x.x.x-min.js (also called minified version). However this can play a vital role in the performance of the web page.

How it affects the performance?
jQuery-1.4.4.js file size is 178 KB as against its minified version jQuery-1.4.4-min.js that is only 76.7 KB in size. So when your page loads in the client?s browser if you are not using minified version, it loads 178 KB file that takes more time to load than 76.7 KB.

What is CDN?
CDN Stands for Content Distribution Network or also called Content Delivery Network is a group of computers placed at various points connected with network containing copies of data files to maximize bandwidth in accessing the data. In CDN a client access a copy of data nearer to the client location rather than all clients accessing
from the one particular server. This helps to achieve better performance of data retrieval by client.

There are two leading CDNs available that hosts jQuery files.

Microsoft - To load jQuery from Microsoft AJAX CDN
jQuery file can be loaded from Microsoft AJAX CDN. For more details, go to http://www.asp.net/ajaxlibrary/cdn.ashx. You will need to keep following tags in your page.

<script type="text/javascript" language="Javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.1.min.js"></script>
Google - To load jQuery from Google Libraries API

jQuery file can be loaded from Google CDN for more details, go to http://code.google.com/apis/libraries/devguide.html. You will need to keep following tag in your page.

<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

No comments:

Post a Comment