Top 50 Jquery Mobile Interview Questions You Must Prepare 27.Jul.2024

Q1. How To Stop Jqm From Auto-enhancing An Element?

To prevent jQuery Mobile form enhancing an element simply add data-role="none" to the element. Here is a select that is the normal, native element instead of the custom jQuery Mobile styled version that normally is seen.

Q2. What Is .bind()?

This is the easiest and quick method to bind events. But the issue with bind() is that it doesn't work for elements added dynamically that matches the same selector. bind() only attach events to the current elements not future element. Above that it also has performance issues when dealing with a large selection.

Q3. Explain Why There Are Two Different Version Of Jquery Library?

The production version is quite useful at development time as jQuery is open source and if you want to change something then you can make those changes in production version. But the deployment version is minified version or compressed version so it is impossible to make changes in it. Because it is compressed, so its size is very less than the production version which affects the page load time.

Q4. Why Do We Use Jquery?

Due to following advantages:

  • Easy to use and learn.
  • Easily expandable.
  • Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
  • Easy to use for DOM manipulation and traversal.
  • Large pool of built in methods.
  • AJAX Capabilities.
  • Methods for changing or applying CSS, creating animations.
  • Event detection and handling.
  • Tons of plug-ins for all kind of needs.

Q5. Can You Please Explain The Difference Between Javascript And Jquery?

JavaScript is a language While jQuery is a library built in the JavaScript language that helps to use the JavaScript language.

Q6. Tell Me How Do You Stop The Currently-running Animation?

Using jQuery ".stop()" method.

Q7. Where Jquery Mobile Works?

jQuery Mobile works on all popular smartphones and tablets.

Q8. What Are Two Different Version Of Jquery Library?

jQuery library comes in 2 different versions:

  1. Production
  2. Deployment

Q9. How To Keep The Submit Text From Showing With Jquery Mobile?

Suppose we are working on a website that has a submit button and forms and such. On this website we using jQuery Mobile, but to keep its stylesheet from interfering we using some jQuery.

jQuery Mobile is doing a weird thing where it is printing the value of the button, in this case "Submit", to the page, even though under it there is a button under it that says "Submit" and actually works.

Q10. Tell Me Can We Have Multiple Document.ready() Function On The Same Page?

YES. We can have any number of document.ready() function on the same page.

Q11. Tell Me How To Disable Jquery Animation?

Using jQuery property "jQuery.fx.off", which when set to true, disables all the jQuery animation. When this is done, all animation methods will immediately set elements to their final state when called, rather than displaying an effect.

Q12. Explain The Starting Point Of Code Execution In Jquery?

The starting point of jQuery code execution is $(document).ready() function which is executed when DOM is loaded.

Q13. Explain .live()?

This method overcomes the disadvantage of bind(). It works for dynamically added elements or future elements. Because of its poor performance on large pages, this method is deprecated as of jQuery 1.7 and you should stop using it. Chaining is not properly supported using this method.

Q14. Tell Me What Are The Slow Selectors In Jquery?

class selectors are the slow compare to ID and element.

Q15. Explain .on()?

Since live was deprecated with 1.7, so new method was introduced named ".on()". This method provides all the goodness of previous 3 methods and it brings uniformity for attaching event handlers.

Q16. How Does Jquery Mobile Theming Work?

The jQuery Mobile theme system separates color and texture from structural styles that define things like padding and dimensions. This allows theme colors and textures to be defined once in the stylesheet and to be mixed, matched, and combined to achieve a wide range of visual effects.

Q17. Explain .delegate()?

The .delegate() method behaves in a similar fashion to the .live() method, but instead of attaching the selector/event information to the document, you can choose where it is anchored and it also supports chaining.

Q18. Tell Me An Example Usage Of Jquery Mobile?

$('div').on('tap', function(event)
{
alert('You tapped an element');
});

Q19. Tell Me How To Check Data Type Of Any Variable In Jquery?

Using $.type(Object) which returns the built-in JavaScript type for the object.

Q20. Explain Finish Method In Jquery?

The .finish() method stops all queued animations and places the element(s) in their final state. This method was introduced in jQuery 1.9.

Q21. Can You Please Explain The Difference Between Parent() And Parents() Methods In Jquery?

The basic difference is the parent() function travels only one level in the DOM tree, where parents() function search through the whole DOM tree.

Q22. Explain Jquery.noconflict?

As other client side libraries like MooTools, Prototype can be used with jQuery and they also use $() as their global function and to define variables. This situation creates conflict as $() is used by jQuery and other library as their global function. To overcome from such situations, jQuery has introduced jQuery.noConflict().

jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});

Q23. Why Is Only The First Page Of Multi Page Document Loaded?

jQuery Mobile currently only supports loading of single page documents via AJAX. To navigate to a multi page document you must disable ajax on the link by adding the data-ajax="false" attribute.

Q24. Why Html 5 Inputs Look Different Across Devices And Browsers?

jQuery Mobile does not have control over the the UI for most of the newer HTML5 input elements like date, color and number. The keyboards and pickers provided are browser-dependent but will safely fall back to a standard input if it's not supported. We do apply basic border and color styles to inputs for these elements so there is some visual consistency.

Q25. Can We Include Multiple Version Of Jquery?

Yes. Multiple versions of jQuery can be included in same page.

Q26. Is It Possible To Use Jquery To Make Ajax Request?

Yes. jQuery can be used for making ajax request.

Q27. Is It Possible To Use Our Own Specific Character In The Place Of $ Sign In Jquery?

Yes.  It is possible using jQuery.noConflict().

Q28. Tell Me Is Jquery A W3c Standard?

No. jQuery is not a W3C standard.

Q29. Explain The Use Of Jquery .each() Function?

The $.each() function is used to iterate over a jQuery object. The $.each() function can be used to iterate over any collection, whether it is an object or an array.

Q30. Tell Me Is Jquery A Library For Client Scripting Or Server Scripting?

Client side scripting.

Q31. How To Divide A Page Into Parts Using Jquery Mobile?

  • Pages normally don't have a fixed height.
  • If you set a page or some element on a page to a fixed height using CSS, then you can size things in terms of %.
  • You'll need to use a bit of Javascript to set the page height.

Here's one way to get the device height:

var viewportHeight = document.documentElement.clientHeight;

Here's another (that I haven't tried, but should work) because jQuery Mobile sets the device height as min-height CSS for the page. (And assuming you already have a $page variable with the page.)

var viewportHeight = parseFloat($page.css('min-height'));

Then, you can:

$page.height(viewportHeight + 'px');

Q32. Can You Please Explain The Difference Between Jquery And Jquery Ui?

jQuery is the core library. jQueryUI is built on top of it. If you use jQueryUI, you must also include jQuery.

Q33. Can You Please Explain The Difference Between .js And .min.js?

jQuery library comes in 2 different versions Production and Deployment. The deployment version is also known as minified version. So .min.js is basically the minified version of jQuery library file. Both the files are same as far as functionality is concerned. but .min.js is quite small in size so it loads quickly and saves bandwidth.

Q34. What Are The Advantage Of Using Cdn?

  • It reduces the load from your server.
  • It saves bandwidth. jQuery framework will load faster from these CDN.
  • The most important benefit is it will be cached, if the user has visited any site which is using jQuery framework from any of these CDN.

Q35. What Is $('div')?

$('div') : This creates a new div element. However this is not added to DOM tree unless you don't append it to any DOM element.

Q36. Tell Me How To Executed Jquery Selectors?

Your last selectors is always executed first. For example, in below jQuery code, jQuery will first find all the elements with class ".myCssClass" and after that it will reject all the other elements which are not in "p#elmID".

Q37. Why We Need Jquery Mobile?

jQuery Mobile is a touch-optimized web framework (additionally known as a JavaScript library or a mobile framework) currently being developed by the jQuery project team. The development focuses on creating a framework compatible with a wide variety of smartphones and tablet computers, made necessary by the growing but heterogeneous tablet and smartphone market. The jQuery Mobile framework is compatible with other mobile app frameworks and platforms such as PhoneGap, Worklight and more.

Q38. Which Are The Fastest Selectors In Jquery?

ID and element selectors are the fastest selectors in jQuery.

Q39. Explain Cdn?

A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet. The goal of a CDN is to serve content to end-users with high availability and high performance.

Q40. Can You Please Explain The Difference Between Body Onload() And Document.ready() Function?

Document.ready() function is different from body onload() function for 2 reasons.

  1. We can have more than one document.ready() function in a page where we can have only one body 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.

Q41. Explain The Basic Need To Start With Jquery?

To start with jQuery, one need to make reference of it's library.

Q42. What Is .empty()?

This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.

Q43. What Is Event.stoppropagation?

event.stopPropagation(): Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. For example, if there is a link with a click method attached inside of a DIV or FORM that also has a click method attached, it will prevent the DIV or FORM click method from firing.

Q44. Explain Event.preventdefault?

The event.preventDefault() method stops the default action of an element from happening. For example, Prevents a link from following the URL.

Q45. What Is .remove()?

Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

Q46. Explain Is Jquery Replacement Of Java Script?

No. jQuery is not a replacement of JavaScript. jQuery is a different library which is written on top of JavaScript. jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML.

Q47. Can You Please Explain The Difference Between Calling Stop(true,true) And Finish Method?

The .finish() method is similar to .stop(true, true) in that it clears the queue and the current animation jumps to its end value. It differs, however, in that .finish() also causes the CSS property of all queued animations to jump to their end values, as well.

Q48. How To Load A Page Using Jquery Mobile?

To load an external page, enhance its content, and insert it into the DOM, use the loadPage method. There are a lot of methods and properties that you can set when loading pages.

Q49. Can You Please Explain The Difference Between Event.preventdefault And "return False"?

e.preventDefault() will prevent the default event from occurring, e.stopPropagation() will prevent the event from bubbling up and return false will do both.

Q50. What To Do 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).