JQuery Interview Questions and Answers
JQuery Interview Questions and Answers
jQueryisafast,lightweight,feature-richclientsideJavaScriptframework.Ithasprovideda
forsmallerfunctionality.
.co
2)IsjQueryaprogramminglanguage?
muchneededboosttoJavaScript.BeforejQuery,JavaScriptcodeswerelengthyandbigger,even
jQueryisnotaprogramminglanguagebutawellwrittenJavaScriptcode.Itisusedtotraverse
documents,eventhandling,AjaxinteractionandAnimation.
3)WhatisthedifferencebetweenJavaScriptandjQuery?
ThesimpledifferenceisthatJavaScriptisalanguagewhilejQueryisabuilt-inlibrarybuiltof
JavaScript.jQuerysimplifiestheuseofJavaScriptlanguage.
4)IsjQueryreplacementofJavaScript?
ar
No,jQueryisnotthereplacementofJavaScript.jQueryiswrittenonthetopofJavaScriptandit
isadifferentlibrary.jQueryislightweightJavaScriptlibrarywhichisusedtointeractJavaScript
andHTML.
er
5)WhydoweusejQuery?
Itisveryeasytolearnanduse.
Itisusedtodevelopbrowsercompatiblewebapplications.
Itimprovestheperformanceofanapplication.
re
Itisveryfastandextensible.
ItfacilitatesyoutowriteminimallinesofcodesforUIrelatedfunctions.
Ca
Itprovidesacross-browsersupport.
6)WhataretheeffectsmethodsusedinjQuery?
ThesearesomeeffectsmethodsusedinjQuery:
show()
hide()
toggle()
fadeIn()
fadeOut()
7)IsitpossiblethatjQueryHTMLworkforbothHTMLandXML
document?
8)Whatis$()injQuerylibrary?
.co
No,jQueryHTMLonlyworksforHTMLdocument.Itdoesn'tworkforXMLdocuments.
The$()functionisanaliasofjQuery()function.ItisusedtowrapanyobjectintojQueryobject
whichlaterfacilitatesyoutocallvariousmethoddefinedjQueryobject.Youcanpassaselector
stringto$()functionanditwillreturnjQueryobjectwhichcontainsanarrayofallmatchedDOM
elements.
9)IsjQuerylibraryusedforserverscriptingorclientscripting?
ItisalibraryforclientsideScripting.
ar
10)IsjQueryaW3Cstandard?
No,jQueryisnotaW3Cstandard.
er
11)WhatisthestartingpointofcodeexecutioninjQuery?
$(document).ready()functionisthestartingpointofjQuerycode.ItisexecutedwhenDOMis
re
loaded.
12)WhatisthebasicrequirementtostartwiththejQuery?
YouneedtomakereferenceofitslibrarytostartwithjQuery.Youcandownloadthelatest
Ca
versionofjQueryfromjQuery.com.
13)Canyouuseaspecialcharacterinplaceof$(dollarsign)in
jQuery?
Yes.
14)Canyouusemultipledocument.ready()functiononthesame
page?
Yes.Youcanuseanynumberofdocument.ready()functiononthesamepage.
15)Whatisthedifferencebetweenfindandchildrenmethods?
FindmethodisusedtofindalllevelsdowntheDOMtreewhilechildrenmethodisusedtofind
.co
singleleveldowntheDOMtree.
16)WhatisaCDN?
CDNstandsforContentDeliveryNetworkorContentDistributionNetwork.Itisalarge
distributedsystemsofserversdeployedinmultipledatacentersacrosstheinternet.
17)WhatisthegoalofCDNandwhataretheadvantagesofusing
CDN?
ThemaingoaloftheCDNistoprovidecontenttotheend-userswithhighavailabilityandhigh
ar
performance.
AdvantagesofusingCDN:
Itreducestheloadfromtheserver.
Itsavesbandwidth.jQueryframeworkisloadedfasterfromtheseCDN.
er
IfauservisitsregularlyasitewhichisusingjQueryframeworkfromanyoftheseCDN,it
willbecached.
re
18)HowcanyouusejQuerylibraryinyourproject?
YoucanusejQuerylibraryinASP.NetprojectfromdownloadingthelatestjQuerylibraryfrom
jQuery.comandincludethereferencestothejQuerylibraryfileinyourHTML/PHP/JSP/Aspx
page.
Ca
<scriptsrc="_scripts/jQuery-1.2.6.js"type="text/javascript">
</ script>
<scriptlanguage="javascript">
$(document).ready(function(){
alert('test')
})
</ script>
19)WhatareselectorsinjQuery?Howmanytypesofselectorsin
jQuery?
Ifyouwanttoworkwithanelementonthewebpage,firstyouneedtofindit.Selectorsare
usedtofindtheHTMLelementsinjQuery.Therearemanytypesofselectors.Somebasic
selectorsare:
Nam e:ItisusedtoselectsallelementswhichmatchwiththegivenelementName.
.co
#I D:ItisusedtoselectsasingleelementwhichmatcheswiththegivenID
.Class:ItisusedtoselectsallelementswhichmatchwiththegivenClass.
U niversal(*):ItisusedtoselectsallelementsavailableinaDOM.
MultipleElem entsE,F,G:Itisusedtoselectsthecombinedresultsofallthespecified
selectorsE,ForG.
AttributeSelector:Itisusedtoselectelementsbasedonitsattributevalue.
20)WhatisuseofjQueryfilter?
:jQueryfilterisusedtofilterthecertainvaluesfromtheobject.Itfilterstheresultofyour
ar
originalqueryintospecificelements.
21)WhatarethedifferenttypesofselectorsinjQuery?
TherearethreetypesofselectorsinjQuery:
er
CSSSelector
CustomSelector
XPathSelector
re
22)WhatisthedifferencebetweenIDselectorandclassselectorin
jQuery?
IDselectorandclassselectoraresameliketheyareusedinCSS.IDselectorusesIDwhileclass
Ca
selectorusesclasstoselectelements.
Ifyouneedtoselectjustoneelement,useIDselector.Ifyouwanttoselectagroupof
elements,havingsameCSSclass,useclassselector.
23)HowtoaddandremoveCSSclassestoanelementusingjQuery?
Youcanuseaddclass()jQuerymethodtoaddCSSclasstoanelementandremoveclass()jQuery
methodtoremoveCSSclassfromanelement.
24)CanyouwriteajQuerycodetoselectalllinksinsidethe
paragraph?
Yes.Youcanuse<a>tagnestedinsideparagraph<p>tagtoselectalllinks.
25)Whatisthedifferencebetweenpropandattr?
.co
attr():Itgetsthevalueofanattributeforthefirstelementinthesetofmatchedelement.
prop():itgetsthevalueofapropertyforthefirstelementinthesetofmatchedelements.Itis
introducedinjQuery1.6.
TherearetwotypesofCDN:
26)WhatarethetwotypesofCDNs?
Microsoft:ItloadsjQueryfromAJAXCDN.
ar
Google:ItloadsjQueryfromGooglelibrariesAPI.
27)WhatistheuseofanimatefunctioninjQuery?
Theanimatefunctionisusedtoapplythecustomanimationeffecttoelements.Syntax:
Here,
er
$(selector).animate({params},[duration],[easing],[callback])
"param"definestheCSSpropertiesonwhichyouwanttoapplytheanimation.
re
"duration"specifyhowlongtheanimationwillrun.Itcanbeoneoffollowingvalues:
"slow","fast","normal"ormilliseconds
"easing"isthestringwhichspecifythefunctionforthetransition.
Ca
"callback"isthefunctionwhichwewanttorunoncetheanimationeffectiscomplete.