jQuery interview questions and answers – Part6

51. How to use migrate jQuery plugin?
with release of 1.9 version of jQuery, many deprecated methods were discarded and they are no longer available. But there are many sites in production which are still using these deprecated features and it’s not possible to replace them overnight. So jQuery team provided with jQuery Migrate plugin that makes code written prior to 1.9 work with it.
So to use old/deprecated features, all you need to do is to provide reference of jQuery Migrate Plugin.

52. How is body onload() function is different from document.ready() function 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.

53. Is it possible to use other client side libraries like MooTools, Prototype along with jQuery?

54. What are selectors in jQuery and how many types of selectors are there?
To work with an element on the web page, first we need to find them. To find the html element in jQuery we use selectors. There are many types of selectors but basic selectors are:
• Name: Selects all elements which match with the given element Name.
• #ID: Selects a single element which matches with the given ID
• .Class: Selects all elements which match with the given Class.
• Universal (*): Selects all elements available in a DOM.
• Multiple Elements E, F, G: Selects the combined results of all the specified selectors E, F or G.
• Attribute Selector: Select elements based on its attribute value.

55. How do you select element by ID in jQuery?
To select element use ID selector. We need to prefix the id with “#” (hash symbol). For example, to select element with ID “txtName”, then syntax would be,

56. What does $(“div”) will select?
This will select all the div elements on page.

57. How to select element having a particular class (“.selected”)?
$(‘.selected’). This selector is known as class selector. We need to prefix the class name with “.” (dot).

58. What does $(“div.parent”) will select?
All the div element with parent class.

59. What are the fastest selectors in jQuery?
ID and element selectors are the fastest selectors in jQuery.

60. What are the slow selectors in jQuery?
class selectors are the slow compare to ID and element.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Get Alert

    Enter your email address:

  • Categories

  • Twitter

Subscribe Now!
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.

Subscribe Here

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter