Sunday, 26 February 2017

Interview Q & A : jQuery Programming

Q1. What is Jquery in the context of web applications.
jQuery is nothing but a collection of well written javascript code.
In other words Jquery is ready made concise and fast JavaScript Library to be used.

Q2. What are the advantages of using jQuery over JavaScript in ASP.NET web application 
Below are the advatages of using jQery over JavaScript

1.Jquery is well written optimised javascript code so
it will be faster in execution unless we write same standard optimised javascript code.
2.Jquery is concise java script code ,means minimal ammount of code
is to be written for the same functionality than the javascript.
3.Javascript related Development is fast using Jquery because most of the
functionality is already written in the library and we just need to use that.
4.Jquery has cross browser support ,so we save time for supporting all the browsers. 

Q3. How to use jQuery in ASP.NET web application 
To use jQuery in ASP.NET web application follow the below steps:
a)Go to official jQuery WebSite)
b)Download latest .js jQuery file from the website.
c)Put it the script(or other folder) in the root of your web application
d)Add the below tag on the page where you want to use Jquery
script type="text/javascript" src="script/jQueryDownLoadedFileName.js" /script

Q4. What is the use of Jquery min js file in ASP.NET web application 
JQuery min .js file is actully a minified version of
Actual JQuery .js. The min files have less size but same content so
this improves the You should prefer to use min files.

Q5. What is the advantages of use of document.ready functions in jQuery 
Advantage of using $(document).ready(function () in jQuery
is that the code inside this function will excecute only when
the full page has been loaded so that there will be no error like
the DOM object on which the Jquery has to execute is not loaded.

Q6. Can we write more than one document.ready jQuery functions in one page 
Yes we can write more than one jquery $(document).ready(function ()
in one page.This is helpful when you have large Jquery code
and you want to split it in multiple files.

Q7. How to select an element with Id in Jquery 
To select an element with Id write as below:
var divValue = $(''#sampleDivId'').val();

Q8. How to select an element with class in Jquery
To select an element with class write as below:
$(".sampleClass").css("border","2px solid blue");

Q9. What is the difference between jQuery find and children methods
The difference between find() and children() methods
are that the children only travels a single level down the DOM tree
while the find travels at all level down the DOM tree.

Q10. How to use length function in jQuery to text existance of an element by Id 
To test if an element exists we can use length method in jQuery as below:
if $(''#mySampleDiv'').length )//Tests wheter the div with id mySampleDiv exists or not

No comments:

Post a Comment