This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How To Use Length Function In Jquery To Text Existance Of An Element By Id? |
|
Answer» 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 $(mySampleDiv).find(''div''); 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 $(mySampleDiv).find(''div''); |
|
| 2. |
What Is The Difference Between Jquery Find And Children Methods? |
Answer»
|
|
| 3. |
How To Select An Element With Class In Jquery? |
|
Answer» To select an ELEMENT with class WRITE as below: $(".sampleClass").css("BORDER","2PX solid blue"); To select an element with class write as below: $(".sampleClass").css("border","2px solid blue"); |
|
| 4. |
How To Select An Element With Id In Jquery? |
|
Answer» To SELECT an element with ID WRITE as below: var divValue = $(''#sampleDivId'').val(); To select an element with Id write as below: var divValue = $(''#sampleDivId'').val(); |
|
| 5. |
Can We Write More Than One Document.ready Jquery Functions In One Page? |
|
Answer» 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. 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. |
|
| 6. |
What Is The Advantages Of Use Of Document.ready Functions In Jquery? |
|
Answer» 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. 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. |
|
| 7. |
What Is The Use Of Jquery Min Js File In Asp.net Web Application? |
|
Answer» 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 performance.so You should PREFER to use min files. 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 performance.so You should prefer to use min files. |
|
| 8. |
How To Use Jquery In Asp.net Web Application? |
|
Answer» To use jQuery in ASP.NET web application follow the below steps:
To use jQuery in ASP.NET web application follow the below steps: |
|
| 9. |
What Are The Advantages Of Using Jquery Over Javascript In Asp.net Web Application? |
|
Answer» Below are the advatages of using jQery over JAVASCRIPT:
Below are the advatages of using jQery over JavaScript: |
|
| 10. |
What Is Jquery In The Context Of Web Applications? |
|
Answer» 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. 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. |
|
| 11. |
Write A Code Snippet To Select All <p> Elements Which Are In All Pages Except First Page? |
|
Answer» <P>Below is the CODE SNIPPET for this SCENARIO: $("p :not(:FIRST)") Below is the code snippet for this scenario: $("p :not(:first)") |
|
| 12. |
Write A Code Snippet To Select <li> Elements Which Are In Index Greater Than 5 And Less Than 10 In Jquery? |
|
Answer» Below is the code snippet for this SCENARIO: <UL>Below is the code snippet for this scenario: |
|
| 13. |
In <table> Design Change The Color Of Even <tr> Elements To “green” And Change The Color Of Odd <tr> Elements To “blue” Color? Give An Example Code? |
|
Answer» Below is the sample CODE snippet for this SCENARIO – $("TR:even").CSS('color','green') $("tr:odd").css('color','blue') Below is the sample code snippet for this scenario – $("tr:even").css('color','green') $("tr:odd").css('color','blue') |
|
| 14. |
How We Can Select The Specified <li> Element From The List Of <li> Elements In <ul>? |
|
Answer» If we want to GET the 4th <li> from the list of elements in <ul> then we can WRITE code as below – $("ul li:eq(3)") // INDEX will start from 0. If we want to get the 4th <li> from the list of elements in <ul> then we can write code as below – $("ul li:eq(3)") // Index will start from 0. |
|
| 15. |
How To Select All The <span> Elements Which Has Text ‘a4academics’? |
|
Answer» We can select all <span> elements USING below CODE – $("span:contains('a4academics’')") We can select all <span> elements using below code – $("span:contains('a4academics’')") |
|
| 16. |
How Can We Select Elements In Two Different Classes In Jquery? |
|
Answer» Below is the SAMPLE CODE for SHOWING how we can do it – $(".MyClass1.MyClass2").CSS('color','green'); Below is the sample code for showing how we can do it – $(".MyClass1.MyClass2").css('color','green'); |
|
| 17. |
Why To Use Jquery Dialog? |
|
Answer» Jquery Dialog is USED like a POP up and if Jquery used in MVC then we can render the cshtml contents in Jquery Dialog and its used like a CONFIRM BOX (as JAVASCRIPT) too. Jquery Dialog is used like a pop up and if Jquery used in MVC then we can render the cshtml contents in Jquery Dialog and its used like a confirm box (as javascript) too. |
|
| 18. |
What Is “unbind” In Jquery? |
|
Answer» “unbind” METHOD is used to remove the EVENT handlers associated to the element. This method can be used with SELECTORS to remove the event handlers of the selected elements. “unbind” method is used to remove the event handlers associated to the element. This method can be used with selectors to remove the event handlers of the selected elements. |
|
| 19. |
Give An Example With Code Snippet For “param” Method? |
|
Answer» customerObj=new Object(); customerObj.name="A4Academics"; customerObj.Designation=”IT”; $("#myControlID").CLICK(function(){ $("span").text($.param(customerObj)); }); Now the span ELEMENT will have VALUE like - “name=A4Academics&Designation=IT” customerObj=new Object(); customerObj.name="A4Academics"; customerObj.Designation=”IT”; $("#myControlID").click(function(){ $("span").text($.param(customerObj)); }); Now the span element will have value like - “name=A4Academics&Designation=IT” |
|
| 20. |
Explain “param” Method In Jquery? |
|
Answer» “PARAM” METHOD is used for object or array in the MANNER of SERIALIZATION. While making AJAX CALLS, param method can be used to serialize the querystrings. “param” method is used for object or array in the manner of serialization. While making AJAX calls, param method can be used to serialize the querystrings. |
|
| 21. |
Explain “slidetoggle” Method In Jquery? |
|
Answer» This method is used to GIVE the animation effects to the elements in Jquery. SlideToggle method uses following parameters:
This method is used to give the animation effects to the elements in Jquery. SlideToggle method uses following parameters: |
|
| 22. |
What Is The Difference Between Methods - “css(‘width’)” And “width()” In Jquery? |
|
Answer» Both methods are used to change the widths of the elements. For EXAMPLE: $(‘#myControlID’).css(‘WIDTH’,’150px’); $(‘#myControlID’).width(150); Above is the code to change the width of the element to 150px. As you can SEE “css(width)” method takes the width in pixels whereas for “width” method no NEED to EXPLICITLY mention the width in pixels. Both methods are used to change the widths of the elements. For example: $(‘#myControlID’).css(‘width’,’150px’); $(‘#myControlID’).width(150); Above is the code to change the width of the element to 150px. As you can see “css(width)” method takes the width in pixels whereas for “width” method no need to explicitly mention the width in pixels. |
|
| 23. |
Why To Use “siblings” Method? Give Sample Code To Demonstrate The Same? |
|
Answer» When we need to GET the list of SIBLING elements then “sibling” method is used on parent element. Selectors can be used to filter the siblings. For example <UL> <li> itemA </li> <li id=”mycontrolID”> itemB </li> <li class=”mycontrolclass”> itemC </li> <li class=”mycontrolclass”> itemD </li> </ul> $(‘li#mycontrolID’).siblings().css(‘color’,’YELLOW’); When we need to get the list of sibling elements then “sibling” method is used on parent element. Selectors can be used to filter the siblings. For example <ul> <li> itemA </li> <li id=”mycontrolID”> itemB </li> <li class=”mycontrolclass”> itemC </li> <li class=”mycontrolclass”> itemD </li> </ul> $(‘li#mycontrolID’).siblings().css(‘color’,’yellow’); |
|
| 24. |
How To Check/uncheck Radio Button Using Attr In Jquery? |
|
Answer» $('#myControlID').ATTR('checked', TRUE); $('#myControlID').attr('checked', FALSE); $('#myControlID').attr('checked', true); $('#myControlID').attr('checked', false); |
|
| 25. |
How To Disable Elements Using “attr” In Jquery? |
|
Answer» $('#myControlID').ATTR('disabled', TRUE); $('#myControlID').attr('disabled', FALSE); $('#myControlID').attr('disabled', true); $('#myControlID').attr('disabled', false); |
|
| 26. |
How To Get The Selected Value Of Dropdown In Jquery? |
|
Answer» Below is the sample code to bind to dropdown (selected) – <select ID="myControlID"> <option value="1">AA</option> <option value="2">BB</option> <option value="3">CC</option> <option value="4">DD</option> </select> Get the selected value – $("#myControlID option:selected").text(); Below is the sample code to bind to dropdown (selected) – <select id="myControlID"> <option value="1">AA</option> <option value="2">BB</option> <option value="3">CC</option> <option value="4">DD</option> </select> Get the selected value – $("#myControlID option:selected").text(); |
|
| 27. |
Explain “resize” Method In Jquery? |
|
Answer» “Resize” METHOD USED with window object. This method will be fired when the size of the browser window CHANGES. For example $( window ).resize(function() { $( "#myControlID" ).APPEND( "<div>Test Content</div>" ); }); As per above snippet when browser window’s size changes, content will be appended to the control – “myControlID”. “Resize” method used with window object. This method will be fired when the size of the browser window changes. For example $( window ).resize(function() { $( "#myControlID" ).append( "<div>Test Content</div>" ); }); As per above snippet when browser window’s size changes, content will be appended to the control – “myControlID”. |
|
| 28. |
Write A Code Snippet To Sort String Array In Jquery? |
|
Answer» Below is the code SNIPPET which is used to sort the STRING array – $(document).ready(function(){ var a4acarray = [ “Apple”,”ORANGE”,”BANANA”]; sortedarray = a4acarray.sort(); $(“#mycontrolID”).HTML(sortedarray.join(“”)); }); Below is the code snippet which is used to sort the string array – $(document).ready(function(){ var a4acarray = [ “Apple”,”Orange”,”Banana”]; sortedarray = a4acarray.sort(); $(“#mycontrolID”).html(sortedarray.join(“”)); }); |
|
| 29. |
Can We Debug Jquery? If Yes, How Can We Do That? |
|
Answer» Yes. We can DEBUG Jquery FILE by USING “debugger” keyword. We can ADD the “debugger” keyword to the line of Jquery file where we have to debug. Yes. We can debug Jquery file by using “debugger” keyword. We can add the “debugger” keyword to the line of Jquery file where we have to debug. |
|
| 30. |
What Are The Parameters Which Are Being Used In Ajax Jquery? |
|
Answer» Below are the list of 4 parameters which are used in AJAX CALLS – Below are the list of 4 parameters which are used in AJAX calls – |
|
| 31. |
Explain Finish Method In Jquery? |
|
Answer» “finish” METHOD is USED to stop the animations of the ELEMENTS and bring the elements to its FINAL state. “finish” method is used to stop the animations of the elements and bring the elements to its final state. |
|
| 32. |
How We Can Get The Value Of Multiple Css In Single Statement Of Jquery? |
|
Answer» Below is the SAMPLE code to explain: VAR Mypropertiescollection = $("#MyControlID").css([ "height", "width", "backgroundColor" ]); In the above code SNIPPET variable – “Mypropertiescollection” will have ARRAY like below – { height: "100PX", width: "200px", backgroundColor: "#FF01EF" } Below is the sample code to explain: var Mypropertiescollection = $("#MyControlID").css([ "height", "width", "backgroundColor" ]); In the above code snippet variable – “Mypropertiescollection” will have array like below – { height: "100px", width: "200px", backgroundColor: "#FF01EF" } |
|
| 33. |
Will Jquery Support Ajax ? Mention Some Ajax Methods Which Can Be Used In Jquery? |
|
Answer»
Below are some of the METHODS of AJAX:
Yes. Jquery supports AJAX. Below are some of the methods of AJAX: |
|
| 34. |
How We Can Write Code Specific To Browser In Jquery? |
|
Answer» By using the property – “Jquery.BROWSER” we can WRITE the browser SPECIFIC CODE. By using the property – “Jquery.Browser” we can write the browser specific code. |
|
| 35. |
Explain Caching In Jquery? |
|
Answer» Caching is TEMPORARY MEMORY to store the data, which increases the performance of the application. So in JQUERY we can use the similar concept to store the data instead of repeating as shown below: Old Code: $('#MyControlID').addClass('test'); $('#MyControlID').css('color', 'yellow'); New Code for caching: var $mycontrol = $("#MyControlID").css("color", "red"); //Do somre STUFFS here $mycontrol.text("Error occurred!"); Caching is temporary memory to store the data, which increases the performance of the application. So in Jquery we can use the similar concept to store the data instead of repeating as shown below: Old Code: $('#MyControlID').addClass('test'); $('#MyControlID').css('color', 'yellow'); New Code for caching: var $mycontrol = $("#MyControlID").css("color", "red"); //Do somre stuffs here $mycontrol.text("Error occurred!"); |
|
| 36. |
Can You Give An Example For Chaining Along With Code Snippet? |
|
Answer» Below is the sample code SNIPPET: Old Code: $(document).ready(function(){ $('#MyControlID').addClass('test'); $('#MyControlID').css('color', 'yellow'); $('#MyControlID').fadeIn('fast'); }); New Code after CHAINING: $(document).ready(function(){ $('#MyControlID').addClass('test') .css('color', 'yellow') .fadeIn('fast'); }); Below is the sample code snippet: Old Code: $(document).ready(function(){ $('#MyControlID').addClass('test'); $('#MyControlID').css('color', 'yellow'); $('#MyControlID').fadeIn('fast'); }); New Code after chaining: $(document).ready(function(){ $('#MyControlID').addClass('test') .css('color', 'yellow') .fadeIn('fast'); }); |
|
| 37. |
Explain Chaining? |
|
Answer» This is one of the powerful or robust feature of JQUERY. Chaining means connecting multiple EVENTS/ selectors/ functions. ADVANTAGE of this would be – code will be EASY to manage and good performance. Chain STARTS from left. This is one of the powerful or robust feature of Jquery. Chaining means connecting multiple events/ selectors/ functions. Advantage of this would be – code will be easy to manage and good performance. Chain starts from left. |
|
| 38. |
How We Can Delay The Execution Of Document.ready Method In Jquery? |
|
Answer» We can use METHOD – “holdReady” for this purpose. Below is the SAMPLE code SNIPPET – $.holdReady(TRUE); We can use method – “holdReady” for this purpose. Below is the sample code snippet – $.holdReady(true); |
|
| 39. |
Can We Include Different Versions Of Jquery In Web Page? |
|
Answer» Yes. We can INCLUDE different VERSIONS of JQUERY in same page. Yes. We can include different versions of Jquery in same page. |
|
| 40. |
Explain The Difference Between “attr” And “prop” In Jquery? |
| Answer» | |
| 41. |
Will Events Are Also Copied On Clone In Jquery? |
|
Answer» By Default “clone” method does not clone the EVENTS unless it is being INSTRUCTED to copy. When “clone” method is being instructed to clone the events also then along with elements, events are also being COPIED. “Clone”method takes a Boolean PARAMETER, PASS true in clone method to copy the events like below - $('#mycontrolid').clone(true).appendTo('body'); By Default “clone” method does not clone the events unless it is being instructed to copy. When “clone” method is being instructed to clone the events also then along with elements, events are also being copied. “Clone”method takes a Boolean parameter, pass true in clone method to copy the events like below - $('#mycontrolid').clone(true).appendTo('body'); |
|
| 42. |
What Is The Use Of Clone Method And Give An Example To Create It In Jquery? |
|
Answer» “Clone” method is used to clone the set of CONTROLS, which basically MEANS to copy the set of ELEMENTS which are matched on selectors. It copies the DESCENDANT elements along with the parent element. For example: $(document).ready(function(){ $('#mycontrolid').click(function(){ $('#mycontrolid').clone().appendTo('body'); return false; }); }); “Clone” method is used to clone the set of controls, which basically means to copy the set of elements which are matched on selectors. It copies the descendant elements along with the parent element. For example: $(document).ready(function(){ $('#mycontrolid').click(function(){ $('#mycontrolid').clone().appendTo('body'); return false; }); }); |
|
| 43. |
How Can We Disable The Animation? |
|
Answer» We can USE the property – “fx.off” to DISABLE the JQUERY animation. Set the property value to TRUE then it will disable the animation in Jquery. We can use the property – “fx.off” to disable the Jquery animation. Set the property value to true then it will disable the animation in Jquery. |
|
| 44. |
Which Method To Be Used To Stop The Animation? |
|
Answer» In Jquery, we have to USE the METHOD CALLED – “STOP()” to stop the ANIMATION. In Jquery, we have to use the method called – “stop()” to stop the animation. |
|
| 45. |
How We Can Implement Animation Effects In Jquery? |
|
Answer» “Animate” method is used for animation in JQUERY. This method is used to change the ELEMENT look and feel and give extra EFFECTS to the ELEMENTS. For example: $("#MyControlID").animate({height:"45px"}); “Animate” method is used for animation in Jquery. This method is used to change the element look and feel and give extra effects to the elements. For example: $("#MyControlID").animate({height:"45px"}); |
|
| 46. |
What Is The Use Of Validation Jquery Plugins? |
|
Answer» In MVC we can USE these Jquery Plugins in the form of rules LIKE below - $('#MyControlId').rules("ADD", { required: TRUE }); In MVC we can use these Jquery Plugins in the form of rules like below - $('#MyControlId').rules("add", { required: true }); |
|
| 47. |
Why To Use “data” Method In Jquery? |
|
Answer» “data” METHOD is used to ATTACH the data to the ELEMENTS in DOM. When the element is removed data also will be removed. For example: jQuery.data( document.body, "a4academics", 40 ); “data” method is used to attach the data to the elements in DOM. When the element is removed data also will be removed. For example: jQuery.data( document.body, "a4academics", 40 ); |
|
| 48. |
Explain Methods “childrens” And “find” In Jquery? |
|
Answer» “Childrens” method is used to find the child controls of the element but its limited to only ONE level where as “find” method can be used to find the controls in any level in DOM TREE. “Childrens” method is used to find the child controls of the element but its limited to only one level where as “find” method can be used to find the controls in any level in DOM tree. |
|
| 49. |
Which Methods Are Used To Provide Effects? |
|
Answer» Below are some of the METHODS USED: Below are some of the methods used: |
|
| 50. |
What Does $("div.parent") Will Select? |
|
Answer» It MEANS SELECT all the div elements with CLASS – “PARENT”. It means select all the div elements with class – “parent”. |
|