Monday, July 15, 2013

jQuery Interview Questions & Answers

1. What Is Jquery?

  • jQuery is a JavaScript Library.
  • jQuery greatly simplifies JavaScript programming.


2. What is advantage of JQuery?

  • jQuery is a lightweight, "write less, do more", JavaScript library.
  • jQuery is easy to learn.


3. What is the purpose of Jquery?

  • The purpose of jQuery is to make it much easier to use JavaScript on your website.
  • jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
  • jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.

4. What are features of Jquery?
The jQuery library contains the following features:

  • HTML/DOM manipulation
  • CSS manipulation
  • HTML event methods
  • Effects and animations
  • AJAX
  • Utilities


5.Will jQuery work in all browsers?

The jQuery team knows all about cross-browser issues, and they have written this knowledge into the jQuery library. jQuery will run exactly the same in all major browsers, including Internet Explorer 6!

6-How can we Adding jQuery to Your Web Pages?
There are several ways to start using jQuery on your web site. You can:

  • Download the jQuery library from jQuery.com
  • Include jQuery from a CDN, like Google


7.Do you wonder why we do not have type="text/javascript" inside the <script> tag?

This is not required in HTML5. JavaScript is the default scripting language in HTML5 and in all modern browsers!

8.One big advantage of using the hosted jQuery from Google or Microsoft:

Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.

9.What is  Document Ready Event?
This is to prevent any jQuery code from running before the document is finished loading (is ready).

10. What are advantages for using Document Ready Event?
It is good practice to wait for the document to be fully loaded and ready before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section. actions that can fail if methods are run before the document is fully loaded:
Trying to hide an element that is not created yet
Trying to get the size of an image that is not loaded yet

11.What is jQuery Selectors?

  • jQuery selectors are one of the most important parts of the jQuery library.
  • jQuery selectors allow you to select and manipulate HTML element(s).
  • jQuery selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.
  • All selectors in jQuery start with the dollar sign and parentheses: $().


12.How Can we select element using JQuery Selector?
The jQuery element selector selects elements based on the element name.
You can select all <p> elements on a page like this:

$("p")

13.What is Id Selectors.

  • The jQuery #id selector uses the id attribute of an HTML tag to find the specific element.
  • An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element.
  • To find an element with a specific id, write a hash character, followed by the id of the element:


$("#test")

14.What is Class Selectors?

  • The .class SelectorThe jQuery class selector finds elements with a specific class. 
  • To find elements with a specific class, write a period character, followed by the name of the class:
          $(".test")

15.What are Events and give some examples?

  • All the different visitor's actions that a web page can respond to are called events.
  • An event represents the precise moment when something happens.Examples.
  • moving a mouse over an elements
  • Selecting a radio button
  • clicking on an element

16.why are we used jQuery Event Methods$(document).ready()?

The $(document).ready() method allows us to execute a function when the document is fully loaded.

17 .what is jQuery Effects?
jQuery afftest are hide, Show, Toggle, Slide, Fade, and Animate. WOW!

18.what are jQuery toggle() method?
With jQuery, you can toggle between the hide() and show() methods with the toggle() method.

Shown elements are hidden and hidden elements are shown:

Example

$("button").click(function(){
  $("p").toggle();
});

19.How many types are  jQuery Fading Methods:
With jQuery you can fade an element in and out of visibility.
jQuery has the following fade methods:

  • fadeIn() 
  • fadeOut()
  • fadeToggle()
  • fadeTo()


20.what is jQuery Sliding Methods
With jQuery you can create a sliding effect on elements.
jQuery has the following slide methods:


  • slideDown()
  • slideUp()
  • slideToggle()


21.Is it possible to manipulate ALL CSS properties with the animate() method?

Yes, almost! However, there is one important thing to remember: all property names must be camel-cased when used with the animate() method: You will need to write paddingLeft instead of padding-left, marginRight instead of margin-right, and so on. Also, color animation is not included in the core jQuery library.

22. what is jQuery stop() Method?

  • The jQuery stop() method is used to stop an animation or effect before it is finished.
  • The stop() method works for all jQuery effect functions, including sliding, fading and custom animations.

23.what is jQuery Callback Functions?

  • A callback function is executed after the current effect is 100% finished.
  • JavaScript statements are executed line by line. However, with effects, the next line of code can be run even though the effect is not finished. This can create errors.
  • To prevent this, you can create a callback function.
  • A callback function is executed after the current effect is finished.


24.What is jQuery Method Chaining?

Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.

25.Without jQuery, AJAX coding can be a bit tricky!
Writing regular AJAX code can be a bit tricky, because different browsers have different syntax for AJAX implementation. This means that you will have to write extra code to test for different browsers. However, the jQuery team has taken care of this for us, so that we can write AJAX functionality with only one single line of code.

26.What is The jQuery noConflict() Method?
The noConflict() method releases the hold on the $ shortcut identifier, so that other scripts can use it.

27.What is Traversing?
jQuery traversing, which means "move through", are used to "find" (or select) HTML elements based on their relation to other elements. Start with one selection and move through that selection until you reach the elements you desire.

No comments:

Post a Comment