Schedule a 30 minute appointment with a client advisor today. Start
Engineering, Design, Marketing, and More

jQuery interview questions

The most popular questions

Use our complementary questions and answers to filter and hire the best. Questions crowdsourced by our clients, answers by Punch. We provide these complementary questions to help our clients more quickly create tests for potential hires at their organizations.

Get a question answered
Punch offers four divisions of services: design, engineering, staffing, and demand

Interview questions for your next interview

Question
How to resolve conflicts with other libraries?”
Answer
By default, jQuery uses $ as a shortcut for jQuery. Thus, if you are using anotherJavaScript library that uses the $ variable, you can run into conflicts with jQuery. In order toavoid these conflicts, you need to put jQuery in no-conflict mode immediately after it isloaded onto the page and before you attempt to use jQuery in your page.
Question
How to remove element from DOM before its Promise is resolved?
Answer
To remove an element from the DOM before its Promise is resolved, use .detach()instead and follow with .removeData() after resolution.

Find developers today

Hire a Punch engineer

Punch offers four divisions of services: design, engineering, staffing, and demand. Our four divisions form the core of our People Forward Approach.

Contact us
Find developers today
Question
Does ‘async’ load asynchronously?
Answer
They are not loaded asynchronously in all browsers. ‘async’ property has beendiscovered to have an effect on dynamically-appended scripts, at least in Firefox and Opera.
Question
What is the best way to add options to a select from an array with jQuery?
Answer
For Example.
array = { "1": "test 1", "2": "test 2" };
$.each(selectValues, function(key, value) {
$('#mySelect')
.append($('<option>', { value : key })
.text(value));
});
Question
What is the best way to fix broken Images automatically?
Answer
This will help in replacing broken Images in Site.
$('img').error(function(){
$(this).attr('src', ‘img/broken.png’);
});
Question
What is the best way to add options to a select from an array with jQuery?
Answer
array = { "1": "One", "2": "Two" };
$.each(array, function(key, value) {
$('#mySelect')
.append($('<option>', { value : key })
.text(value));
});
Question
How to add Confirmation dialog in Jquery?
Answer
$('<div></div>').appendTo('body')
.html('<div><h6>Yes or No?</h6></div>')
.dialog({
modal: true,
title: 'message',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: false,
buttons: {
Yes: function () {
doFunctionForYes();
$(this).dialog("close");
},
No: function () {
doFunctionForNo();
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
Question
How to automatically resize jQuery UI to the width of the container by ajax?
Answer
var $dialog; //Must be at the global scope
function dialog(url) {
$dialog.dialog("option", "width", "auto");
$dialog.dialog("option", "height", "auto");
$.get(url,{},function(html) {
$dialog.html(html);
$dialog.dialog("open");
});
}

$(function() {
//Initialize (without showing it)
var $dialog = $('<div id="dialog" title=""></div>').dialog({
autoOpen: false,
modal: true
});
});
Question
What are queue() and dequeue() in jQuery?
Answer
Queues in jQuery are used for animations. You can use them for any purpose you like.They are an array of functions stored on a per element basis, using jQuery.data(). They areFirst-In-First-Out (FIFO). You can add a function to the queue by calling .queue(), and youremove (by calling) the functions using .dequeue().

Ask a question

Ask a question, and one of our engineers will answer it.

We keep our questions nice and simple to be useful for everyone, and we may not answer or publish every question.

Your number is stored privately and never shared.
By submitting a question, you agree to our terms.
Request sent. Thank you!
Send another one