Wednesday 20 January 2016

jQuery UI Interview Questions and Answers

 jQuery UI Interview Questions and Answers

Question: What is jQuery UI? It is JavaScript Library which is collection of jQuery widgets like datepicker, tabs, autocomplete etc. We can also add effects, interactions (drag, drop, resize) on widgets.

  Question: What widets are available in jQuery UI?
  1. Accordion
  2. Autocomplete
  3. Button
  4. Datepicker
  5. Dialog
  6. Menu
  7. Progressbar
  8. Selectmenu
  9. Slider
  10. Spinner
  11. Tabs
  12. Tooltip

Question: What are different effects available in jQuery UI
  1. Add Class
  2. Color Animation
  3. Easing
  4. Effect
  5. Hide
  6. Remove Class
  7. Show
  8. Switch Class
  9. Toggle
  10. Toggle Class

Question: In which language, JQuery UI is written?

Question: Is JQuery UI opensource?
Question: What is current stable version of JQuery UI?
1.11.4 / dated 11 March 2015

Question: From where we can download the jQuery UI

Question: Can we download custom widgets from jQuery UI
Yes, We can.

Question: How to add CSS property on last div?
$('div:last').css({backgroundColor: 'green', fontWeight: 'bolder'});

Question: What is $.noConflict()?
<script src="" type="text/javascript"></script>
<script type="text/javascript">

When we call to $.noConflict(). Old references of $ are saved during jQuery initialization, noConflict() simply restores them.

Question: Can we use another variable instead of $ in jQuery? If yes, How?
Yes, we can.
var jQ = jQuery.noConflict();
/** Now use jQ instead of $ **/
jQ( "div#pid" ).hide();

Question: How to remove close button on the jQuery UI dialog using CSS?
.ui-dialog-titlebar-close {
  visibility: hidden;

Question: How to remove close button on the jQuery UI dialog using JavaScript?
   closeOnEscape: false,
   open: function(event, ui) { $(".ui-dialog-titlebar-close", ui.dialog | ui).hide(); }

Question: How to initialize a dialog without a title bar?
var dialogOpts=[]
//Remove the title bar

Question: How to call Hook into dialog close event in jQuery UI?
$('div#contentId').on('dialogclose', function(event) {
     //console.log('closed event called');

Question: How to Download jQuery UI CSS from Google's CDN?

Question: How to "Change button text" in JQuery?
jQuery Version < 1.6
$("#elementId").attr('value', 'Save'); //versions older than 1.6

jQuery Version > 1.6
$("#elementId").prop('value', 'Save'); //versions newer than 1.6

Question: How can I disable a button in a jQuery ?
$('#divId').attr("disabled", true);

Question: How do I keep jQuery UI Accordion collapsed by default?
$("#divId").accordion({ header: "h4", collapsible: true, active: false });

Question: How to call a dragable widget?
// Make #draggable draggable
$(function () {

Question: How do I disable a jquery-ui draggable of widget?
//myObject is widget object.
myObject.draggable( 'disable' );

OR, you can set during the initalization
    draggable: false

How to remove JQuery UI Autocomplete Helper text?
.ui-helper-hidden-accessible { display:none; }

Question: How to set year in DatePicker?
    yearRange: '1950:2013', 
   changeMonth: true,
   changeYear: true,
   showButtonPanel: true,

Question: How to set current Date in Date Picker?
$(".datepickerClass").datepicker('setDate', new Date());

Question: How to Change Date Format in jQuery UI DatePicker?
var date = $('#datepickerDivId').datepicker({ dateFormat: 'dd-mm-yy' }).val();