Upwork Jquery Skill Test 2018 Version

1. Consider the following code snippet:
<ul id=’id1′>
<li id=’li1′>Items 1</li>
<li id=’li2′>Items 2</li>
<li id=’li3′>Items 3</li>
</ul>

Which of the following code snippets return(s) a set of all li tags within “id1” except for the li tag with id li2?
Answers:
>>>>>>>>>>>> • $(‘#id1 li’).not($(‘#li2’));
• $(‘#id1 li’).except($(‘#li2’));
• $(‘#id1 li’).remove($(‘#li2’));
• $(‘#id1 li’).delete($(‘#li2’));
2. $(‘#a1’).one(‘click’, {times: 3}, function1);

Which of the following is true for the above?
Answers:
>>>>>>>>>>>> • function1 will be executed once regardless of the number of times a1 is clicked.
• function1 will be executed at most 3 times if a1 is clicked more than twice.
• There is at most one instance of function1 to be executed at a time.
• There are at most three instances of function1 to be executed at a time.

3. $(“div”).find(“p”).andSelf().addClass(“border”);
The statement adds class border to ___.
Answers:
>>>>>>>>>>>> • all div tags and p tags in div tags
• all div tags
• all p tags
• all p tags enclosed in div tags

4. What is the result of NaN == NaN?
Answers:
• true
>>>>>>>>>>>> • false
• An error occurs.
• None of these.

5. Consider the following code snippet:
$(‘#id1’).animate({width:”240px”}, { queue:false, duration:1000 }).animate({height:”320px”}, “fast”);
The order of the animations of this code snippet is ___.
Answers:
• First the width animation, then the height animation.
>>>>>>>>>>>> • First the height animation, then the width animation.
• Both the width animation and the height animation occur at the same time.
• The order of animations is random.

6. Consider the following code snippet:
$(document).ready(function() {
$(‘div’).each(function(index) {
alert(this);
});
});
Which of the following objects does the ‘this’ variable refer to?
Answers:
• window
• document
>>>>>>>>>>>> • The current div tag of the iteration.

• The last element tag in the body.
7. Which of the following returns the children tags of “id1”?
Answers:
>>>>>>>>>>>> • $(‘#id1’).children();
• $(‘#id1’).getChildren();
• children(‘#id1’);
• getChildren(‘#id1’);

8. Which of the following is the correct way to select an option based on its text in jQuery?
Answers:
>>>>>>>>>>>> • $(“#myselect option”).filter(function(){ return $(this).text() == ‘text’;}).prop(‘selected’, true);
• $(“#myselect option”).prop(‘selected’, true).text(“text”)
• $(“#myselect”).filter(“option”).prop(‘selected’, true).text(“text”);
• $(“#myselect”).filter(function(){ return $(this).val() == ‘text’;}).prop(‘selected’, true);

9. offset function gets the current offset of the first matched element in pixels relative to the ___.
Answers:
>>>>>>>>>>>> • document
• parent element
• children element
• container

10. Which option can be used to have jQuery wait for all images to load before executing something on a page?
Answers:
• All jQuery code need to add inside $function() { } syntax
>>>>>>>>>>>> • With jQuery, can use $(document).ready() to execute something when the DOM is loaded and

$(window).load() to execute something when all other things are loaded as well, such as the images.
• With jQuery, can use $(document).ready() or $(window).load() syntax as these both are the same.
• $(window).onLoad(function() { })

11. What does $(‘tr.rowClass:eq(1)’); return?
Answers:
>>>>>>>>>>>> • One element set which is the second row of the first table.
• One element set which is the first row of the first table.
• A set of tr tags which have “rowClass:eq(1)” class .
• A set of tr tags which have “eq(1)” class .

12. jQuery allows you to use ___ function to switch between showing and hiding an element.
Answers:
• show
• hide
• switch
>>>>>>>>>>>> • toggle

13. Consider the following code snippet:
$(‘#ul1 li’).live(‘click’, function1);
$(‘#ul1’).after(‘<li id=”lastLi”>Last item</li>’);
Is function1 executed if “lastLi” is clicked?
Answers:
• Yes
>>>>>>>>>>>> • No
• “lastLi” does not exist.

14. Consider the following code snippet:
$(‘a.arrow-1’).click(function () {
$(‘.second-row’).slideUp();
$(this).parent(‘.first-row’).siblings(‘.second-row’).slideDown();
});
The order of the animations of this code snippet are:
Answers:
• The targeted parent sibling .second-row will slide up, then .second-row will slide down.
>>>>>>>>>>>> • second-row will slide up, then the targeted parent sibling .second-row will slide down.
• Both the targeted parent sibling .second-row will slide down and the .second-row will slide up actions will occur

at the same time.
• None of the above.

15. Assume that you want that first the tag with “id1” fades out and then the tag with “id2” fades in. Which of the

following code snippets allow(s) you to do so?
Answers:
• $(‘#id1’).fadeOut(‘fast’); $(‘#id2’).fadeIn(‘slow’);
• $(‘#id2’).fadeIn(‘slow’); $(‘#id1’).fadeOut(‘fast’);
>>>>>>>>>>>> • $(‘#id1’).fadeOut(‘fast’, function() {$(‘#id2’).fadeIn(‘slow’)});
• $(‘#id2’).fadeIn(‘slow’, function() {$(‘#id1’).fadeOut(‘fast’)});

16. Which of the following methods can be used to copy element?
Answers:
>>>>>>>>>>>> • clone
• cloneTo
• move
• moveTo

17. $(‘#id1’).animate({width:”80%”}, “slow”)
The above code snippet will ___.
Answers:
>>>>>>>>>>>> • animate the tag with id1 from the current width to 80% width.
• animate the tag with id1 from 80% width to current width.
• animate the tag with id1 from the current 80% width to 0px.
• animate the tag with id1 from 80% width to 100% width.

18. The hide() function hides an element by ___.
Answers:
>>>>>>>>>>>> • setting “display” inline style attribute of that element to “none”.
• setting “visibility” inline style attribute of that element to “hidden”.
• setting the horizontal attribute of that element to “-100”.
• setting the vertical attribute of that element to “-100”.

19. Consider the following code snippet:
$(‘#table1’).find(‘tr’).filter(function(index) { return index % 3 == 0}).addClass(‘firstRowClass’);
The result of the above code snippet is ___.
Answers:
>>>>>>>>>>>> • The rows of table1 at order 3n + 1 (n = 0, 1, 2,…) will belong to the class firstRowClass.
• The rows of table1 at order 3n (n = 1, 2,…) will belong to the class firstRowClass.
• All rows of table1 will belong to the class firstRowClass.
• No row of table1 will belong to the class firstRowClass.

20. One advantage of $.ajax function over $.get or $.post is that ___.
Answers:
>>>>>>>>>>>> • $.ajax offers error callback option.
• $.ajax is easier to use.
• $.ajax allows passing request parameters.
• the result of $.ajax is formatted.

21. Using an element of some kind that is being hidden using .hide() and shown via .show(). Which of the following is

the best way to determine if that element is currently hidden or visible on the screen?
Answers:
>>>>>>>>>>>> • $(element).is(“:visible”)
• $(this).css(“visibility”) == “hidden”
• $(element).is(“:invisible”)
• $(this).css(“visibile”) == “hidden”

22. Which of the following will get the first column of all tables using jQuery?
Answers:
• $(‘table.tblItemTemplate first-child’);
• $(‘table.tblItemTemplate tr:first-child’);
>>>>>>>>>>>> • $(‘table.tblItemTemplate td:first-child’);
• $(‘tabletblItemTemplate td:first-child’);

23. Which option is correct to use the below function to set cursor position for textarea?
Function:
$.fn.selectRange = function(start, end) {
return this.each(function() {
if (this.setSelectionRange) {
this.focus();
this.setSelectionRange(start, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd(‘character’, end);
range.moveStart(‘character’, start);
range.select();
}
});
};
Answers:
>>>>>>>>>>>> • $(‘#elem’).selectRange(3,5);
• $(‘#elem’).selectRange(3 5);
• $(‘#elem’).selectRange(X:3,Y:5);
• $(‘#elem’).fn.selectRange(3,5);

24. Assuming that the jQuery UI library is used to make a list sortable, which of the following code snippets makes

“list1” sortable?
Answers:
>>>>>>>>>>>> • $(‘#list1’).sortable();
• $(‘#list1’).changeable();
• $(‘#list1’).interchangeable();
• $(‘#list1’).organizeable();

25. Which of the following is the correct way to disable an input field with jQuery?
Answers:
>>>>>>>>>>>> • $(“input”).attr(‘disabled’,’disabled’);
• $(“input”).css(‘disabled’,’disabled’);
• $(“input”).attr(‘disable’,’disable’);
• $(“input”).(‘disabled’);

26. Which of the following functions can be used to stop event propagation?
Answers:
>>>>>>>>>>>> • stopPropagation
• disablePropagation
• cancelPropagation
• preventPropagation

27. How can the child img be selected inside the div with a selector?
Answers:
• jQuery(this).children(“img”);
>>>>>>>>>>>> • jQuery(this).find(“img”);
• $(this).find(“img”).attr(“alt”)
• $(this).children(“img”).attr(“alt”)

28. jQuery allows simulating an event to execute an event handler as if that event has just occurred by using ___.
Answers:
>>>>>>>>>>>> • trigger function
• execute function
• intimate functionde
• jQuery does not have this feature.

29. Which of the following is the correct use of ajaxStart() function?
Answers:
• ajaxStart() function is used to start ajax call.
>>>>>>>>>>>> • ajaxStart() function is used to run some code when ajax call start.
• a & b
• None of the above.

30. The height function returns the height of an element in ___.
Answers:
>>>>>>>>>>>> • pixel units
• point units
• em units
• millimeter units

31. Which of the following values is/are valid value(s) of secondArgument in addClass(‘turnRed’, secondArgument);

function, if the jQuery UI library is being used?
Answers:
• ‘fast’
• slow
• 1000ms
>>>>>>>>>>>> • 3000

32. Which of the following methods can be used to utilize the animate function with the backgroundColor style

property?
Answers:
• Use the jQuery UI library.
>>>>>>>>>>>> • There is no need to do anything as jQuery core already supports that style property.
• There is no way to use animate with that style property.

33. Which of the following code snippets insert(s) the code snippet
<div class=”footer”>footer</div>
at the end of div tags?
Answers:
>>>>>>>>>>>> • $(‘div’).append(‘<div class=”footer”>footer</div>’);
• $(‘div’).appendTo(‘<div class=”footer”>footer</div>’);
• $(‘<div class=”footer”>footer</div>’).append(‘div’);
• $(‘<div class=”footer”>footer</div>’).appendTo(‘div’);

34. Which option is correct to perform a synchronous AJAX request?
Answers:
• beforecreate: function(node,targetNode,type,to) { jQuery.ajax({ url: ‘http://example.com/catalog/create/’ +

targetNode.id + ‘?name=’ + encode(to.inp[0].value), success: function(result) { if(result.isOk == false) alert

(result.message); } }); }
• beforecreate: function(node,targetNode,type,to) { jQuery.ajax({ url: ‘http://example.com/catalog/create/’ +

targetNode.id + ‘?name=’ + encode(to.inp[0].value), success: function(result) { if(result.isOk == false) alert

(result.message); }, async: sync(true) }); }
>>>>>>>>>>>> • beforecreate: function(node,targetNode,type,to) { jQuery.ajax({ url:

‘http://example.com/catalog/create/’ + targetNode.id + ‘?name=’ + encode(to.inp[0].value), success: function(result)

{ if(result.isOk == false) alert(result.message); }, async: false }); }
• jQuery only allow asynchronous AJAX request.

35. Which of the following is the correct way to get “Option B” with the value ‘2’ from following HTML code in

jQuery?
<select id=’list’>
<option value=’1′>Option A</option>
<option value=’2′>Option B</option>
<option value=’3′>Option C</option>
</select>
Answers:
• $(“#list[value=’2′]”).text();
>>>>>>>>>>>> • $(“#list option[value=’2′]”).text();
• $(this).find(“option:selected”).text();
• element.options[element.selectedIndex].text

36. Consider the following code snippet:
<ul id=’id1′>
<li id=’li1′>Items 1</li>
<li id=’li2′>Items 2</li>
<li id=’li3′>Items 3</li>
</ul>
Which of the following code snippets returns the same result as $(‘#id1 li’).not($(‘#li2’));?
Answers:
>>>>>>>>>>>> • $(‘#li2’).siblings();
• $(‘#id2’).siblings(‘#li2’);
• $(‘#li2’).children();
• $(‘#id2’).children(‘#li2’);

37. If jQuery is included before another library, how can conflict between jQuery and that library be avoided?
Answers:
>>>>>>>>>>>> • By calling jQuery.noConflict(); right after including jQuery.
• By calling jQuery.useDefault = false; right after including jQuery.
• By calling jQuery.useShortcut = false; right after including jQuery.
• By using the jQuery object when working with the jQuery library and using the $ object for other libraries.

38. Which of the following functions is/are built-in jQuery regular expression function(s)?
Answers:
• test
>>>>>>>>>>>> • match
• find
• jQuery does not have built-in regular expression functions.

39. each() is a generic ___ function.
Answers:
• comparator
• operator
>>>>>>>>>>>> • iterator
• normal

40. Consider the following code snippet:
$(‘span.item’).each(function (index) {
$(this).wrap(‘<li>Item</li>’);
});
What does this code snippet do?
Answers:
>>>>>>>>>>>> • Wraps each span tag that has class item within a li tag.
• Inserts each span tag that has class item into a li tag.
• Inserts <li>Item</li> into each span that has item class.
• Replaces each span tag that has class item with a <li>Item</li>.

41. Consider the following code snippet:
$(document).ready(function1);
$(document).ready(function2);
$(document).ready(function3);
Which of the following functions are executed when DOM is ready?
Answers:
• function1
• function2
• function3
>>>>>>>>>>>> • function1, function2, and function3
• No function is executed.

42. Which of the following represents the best way to make a custom right-click menu using jQuery?
Answers:
>>>>>>>>>>>> • $(document).bind(“contextmenu”, function(event) { event.preventDefault(); $(“<div class=’custom-

menu’>Custom menu</div>”) .appendTo(“body”) .css({top: event.pageY + “px”, left: event.pageX + “px”}); });
• $(document).bind(“contextrightmenu”, function(event) { event.preventDefault(); $(“<div class=’custom-menu’>Custom

menu</div>”) .appendTo(“body”) .css({top: event.pageY + “px”, left: event.pageX + “px”}); });
• $(document).bind(“rightclick”, function(event) { event.preventDefault(); $(“<div class=’custom-menu’>Custom

menu</div>”) .appendTo(“body”) .css({top: event.pageY + “px”, left: event.pageX + “px”}); });
• None of the above.

43. Consider the following code snippet:
$(‘#button1’).bind(‘click’, function(data) {…});
What is the data argument?
Answers:
• Click event’s data
>>>>>>>>>>>> Function’s data
• Global variable
• Local variable

44. What is the result of this function: jQuery.makeArray ( true )?
Answers:
• 1
• NaN
>>>>>>>>>>>> • [ true ]
• []

45. Which of the following is the correct way to get the value of a textbox using id in jQuery?
Answers:
• $(“.textbox”).text()
>>>>>>>>>>>> • $(“#textbox”).val()
• $(“.textbox”).val()
• $(“#textbox”).text()

46. Which of the following is the correct way to add an additional option and select it with jQuery?
Answers:
>>>>>>>>>>>> • $(‘#mySelect’).append(‘text’).val(‘whatever’)
• $(‘#mySelect’).html(‘text’).val(‘whatever’)
• $(‘#mySelect’).text(‘text’).val(‘whatever’)
• $(‘#mySelect’).val(‘whatever’)

47. How can the href for a hyperlink be changed using jQuery?
Answers:
• $(“a”).link(“http://www.google.com/”);
• $(“a”).change(“href”,”http://www.google.com/”);
• $(“a”).link(“href”,”http://www.google.com/”);
>>>>>>>>>>>> • $(“a”).attr(“href”, “http://www.google.com/”);

48. The position function gets the ___ positions of an element that are relative to its offset parent.
Answers:
>>>>>>>>>>>> • top and left
• top and right
• bottom and left
• bottom and right

49. Which of the following is the correct way to debug JavaScript/jQuery event bindings with Firebug or a similar

tool?
Answers:
>>>>>>>>>>>> • var clickEvents = $(‘#foo’).data(“events”).click; jQuery.each(clickEvents, function(key, value) {

console.log(value) // prints “function() { console.log(‘clicked!’) }” })
• $.fn.listHandlers = function(events, outputFunction) { return this.each(function(i){ var elem = this, dEvents =

$(this).data(‘events’); if (!dEvents) {return;} $.each(dEvents, function(name, handler){ if((new RegExp(‘^(‘ +

(events === ‘*’ ? ‘.+’ : events.replace(‘,’,’|’).replace(/^on/i,”)) + ‘)$’ ,’i’)).test(name)) { $.each(handler,

function(i,handler){ outputFunction(elem, ‘n’ + i + ‘: [‘ + name + ‘] : ‘ + handler ); }); } }); }); };
• var clickEvents = $(‘#foo’).data(“events”).click; jQuery.each(clickEvents, function(key, value) {

event.console.log(value); })
• $.fn.listHandlers = function(events, outputFunction) { return this.each(function(i){ var elem = this, dEvents =

$(this).data(‘events’); $.each(dEvents, function(name, handler){ if((new RegExp(‘^(‘ + (events === ‘*’ ? ‘.+’ :

events.replace(‘,’,’|’).replace(/^on/i,”)) + ‘)$’ ,’i’)).test(name)) { $.each(handler, function(i,handler){

outputFunction(elem, ‘n’ + i + ‘: [‘ + name + ‘] : ‘ + handler ); }); } }); }); };

50. Which of the following events can be used to disable right click contextual menu?
Answers:
>>>>>>>>>>>> • contextmenu
• contextualmenu
• rightclickmenu
• The right-click contextual menu cannot be disabled.

51. Which of the following gets the href attribute of “id1”?
Answers:
>>>>>>>>>>>> • $(‘#id1).attr(‘href’);
• $(‘#id1’).getAttribute(‘href’);
• $(‘#id1)[0].attr(‘href’);
• All of these.

52. Which of the following is the correct way to manage a redirect request after a jQuery Ajax call?
Answers:
>>>>>>>>>>>> • $.ajax({ type: “POST”, url: reqUrl, data: reqBody, dataType: “json”, success: function(data,

textStatus) { if (data.redirect) { // data.redirect contains the string URL to redirect to window.location.href =

data.redirect; } else { // data.form contains the HTML for the replacement form $(“#myform”).replaceWith(data.form);

} } });
• public ActionResult Index(){ if (!HttpContext.User.Identity.IsAuthenticated) { HttpContext.Response.AddHeader

(“REQUIRES_AUTH”,”1?); } return View() }
• $.ajax( error: function (jqXHR, timeout, message) { var contentType = jqXHR.getResponseHeader(“Content-Type”); if

(jqXHR.status === 200 && contentType.toLowerCase().indexOf(“text/html”) >= 0) { window.location.reload(); } });
• $(document).ready(function () { $(document).ajaxSend( function(event,request,settings) { var intercepted_success =

settings.success; settings.success = function( a, b, c ) { if( request.responseText.indexOf( “<html>” ) > -1 )

window.location = window.location; else intercepted_success( a, b, c ); }; }); });

53. Which of the following is the correct way to change the image source during click event of a button in jQuery?
Answers:
• $(“#button”).click(function(){ $(“img”).src(); });
>>>>>>>>>>>> • $(“#button”).click(function(){$(“img”).attr(); });
• $(“#button”).submit(function(){$(“img”).text();});
• $(“#button”).submit(function(){$(“img”).html(); });

54. What is the purpose of $(document).ready() function in Jquery?
Answers:
• To execute functions after all content and images are loaded
>>>>>>>>>>>> • To execute functions after DOM is loaded
• To execute functions before DOM load
• To execute functions before content and images load

55. Which of the following will show an alert containing the content(s) of a database selection?
Answers:
>>>>>>>>>>>> • $.ajax({ type: “GET”, url: “process_file.php?comp_id=”+comp_id, success: function (result) { alert

(result); } });
• $.ajax({ type: “GET”, success: function (result) { alert(result); } });
• $.ajax({ type: “GET”, url: “process_file.php?comp_id=”+comp_id, error: function (result) { alert(result); } });
• $.ajax({ type: “GET”, url: “process_file.php?comp_id=”+comp_id, Complete: function (result) { alert(result); } });

56. How can an Ajax request that has not yet received a response be canceled or aborted?
Answers:
>>>>>>>>>>>> • //xhr is an Ajax variable xhr.abort()
• //xhr is an Ajax variable xhr.cancel()
• //xhr is an Ajax variable xhr.die()
• //xhr is an Ajax variable xhr.destroy()

57. Which of the following functions will return an empty set when end() function is chained right after that

function?
Answers:
• add
• children
>>>>>>>>>>>> • filter
• remove

58. Consider the following code snippet:
var message = ‘Message’;
$(‘#id1’).bind(‘click’, function() {
alert(message);
});
message = ‘New message’;
$(‘#id2’).bind(‘click’, function() {
alert(message);
What does the alert box display if «id1» is clicked?
Answers:
>>>>>>>>>>>> • Message
• New message
• Nothing
• None of these

59. Which of the following is correct with regards to how to upload a file asynchronously with jQuery?
Answers:
• In HTML5 file can be uploaded using Ajax and jQuery. Not only that, file validations(name,size,MIME-type) and

handling the progress event can also be done with the HTML5 progress tag(or a div).
• $(‘#one-specific-file’).ajaxfileupload({
‘action’: ‘/upload.php’
});
• Ajax file uploads cannot be done.
>>>>>>>>>>> • $(document).ready(function() {
$(«#uploadbutton»).jsupload({
action: «addFile.do»,
onComplete: function(response){
alert( «server response: » + response);
}
});

60. Consider the following code snippet:
$.map(array1, function1);
Which of the following arguments is/are valid arguments of function1?
Answers:
>>>>>>>>>>>> • The index of the element to be translated in array1.
>>>>>>>>>>>> • The item to be translated.
• function1 has no arguments.
• Both the index of the element to be translated in array1 and the item to be translated.

61. Which of the following is the correct way to distinguish left and right mouse click event in jQuery?
Answers:
• event.what
>>>>>>>>>> • event.which
• event.click
• event.whichclick

62. Which of the following will select a particular option in a <select> element using its index?
Answers:
• $(‘select option[value=»1?]’)
• $(‘select option:eq(1)’)
• $(‘select option:contains(«Selection 1»)’)
• All of the above.

63. $.merge(array1, array2);
The above function merges ___.
Answers:
• array1 into array2.
>>>>>>>>>> • array2 into array1.
• array1 with array2 and returns the result.
• The statement is invalid. The correct one is array1.merge(array2);

64. Which of the following makes use of jQuery to select multiple elements?
Answers:
• $(‘table td’).eq([0, 5, 9])
>>>>>>>>>> • $(‘table td:eq(0), table td:eq(5), table td:eq(9)’)
• $(‘table td’).eqAny([1, 5, 9]);
• None of these.

65. Whats the right way to access the contents of an iframe using jQuery?
Answers:
>>>>>>>>>>>>>> • If the <iframe> is from the same domain, the elements are easily accessible as
$(«#iFrame»).contents().find(«#someDiv»).removeClass(«hidden»);
• $(‘#frametest’).HTML()
• $(‘some selector’, frames[‘nameOfMyIframe’].document).innerHTML()
• All of Above

66. Which of the following is the correct way to select <a> on the basis of href using jQuery?
Answers:
• jQuery(«a»).href()
• jQuery(«a»).attr(«href»)
>>>>>>>>>>> • jQuery(«a[href=’url’]»)
• jQuery(«a attr[href=’url’]»)

67. Which of the following values is/are valid argument(s) of the eq() function?
Answers:
• 1
>>>>>>>>>> • ‘2’
• Both 1 and ‘2’.
• Neither 1 nor ‘2’.

68. Which of the following is the correct way to check the existence of an element in jQuery other than the following

code?
if ($(selector).length>0) {
// Do something
}
Answers:
>>>>>>>>>>>>> • jQuery.fn.exists = function(){return this.length>0;}
if ($(selector).exists()) {
// Do something
}
• jQuery.fn = function(){return this.length>0;}
if ($(selector).exists()) {
// Do something
}
• jQuery.exists = function(selector) {return ($(selector).length &gt; 0);}
if ($.exists(selector)) { }
• jQuery.fn.exists = function(selector) {
return selector ? this.find(selector).length : this.length;
};

69. Which of the following is the correct way to use jQuery with node.js?
Answers:
• By including jQuery library file
>>>>>>>>> • By installing jQuery npm module
• By directly using jQuery without jQuery library file and jQuery npm module
• By including jQuery library file and installing jQuery npm module

70. Which of the following methods can be used to load data?
Answers:
>>>>>>>>>>> • getJSON.
>>>>>>>>>>> • get.
• ajaxSend.
• ajaxStart.

71. What is the difference between jQuery’s .focusout() and .blur() events?
Answers:
>>>>>>>>>>> • The .focusout() event is sent to an element when it, or any element inside of it, loses focus, while the .blur()

event supports detecting the loss of focus from parent elements.
• The .blur() event is sent to an element when it, or any element inside of it, loses focus, while the .focusout()

event supports detecting the loss of focus from parent elements.
• There is no difference between the .focusout() and .blur() events; the two can be used interchangeably.
• None of the above.

72. Which of the following is the correct way to assign a selected value of a drop-down list using jQuery?
Answers:
• $(«#myDDL»).val(2);
• $(«.myDDL»).children(«option»).val(2);
• $(«.myDDL»).val(‘2’);
• $(«.myDDL»).children(«option»).innerText(‘2’);

73. How or where can a plugin be declared, so that the plugin methods are available for the script?
Answers:
>>>>>>>>>>> • In the head of the document, include the plugin after main jQuery source file, before the script file.
• In the head of the document, include the plugin after all other script tags
• In the head of the document, include the plugin before all other script tags.
• Anywhere in the document.

74. Which of the following is the best way to open a jQuery UI dialog box without a title bar?
Answers:
• $(«#ui-dialog-titlebar»).hide();
>>>>>>>>>>> • $(«.ui-dialog-titlebar»).hide();
• $(«#dialog»).siblings(‘div#ui-dialog-titlebar’).remove();
• $(«.ui-titlebar»).hide();

75. Which of the following functions moves p tags that have para class to div with content id?
Answers:
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).appendTo(‘#content’);
});
}
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).append(‘#content’);
});
}
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).insertAfter(‘#content’);
});
}
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).after(‘#content’);
});
}

76. Which of the following will detect a change in the value of a hidden input?
Answers:
• $(‘#id_inpout’).live(‘change’,function () {
var id_el = $(this).attr(‘id’);
alert(id_el);
});
• $(‘#id_inpout’).change(function () {
var id_el = $(this).attr(‘id’);
alert(id_el);
});
• $(‘#id_inpout’).bind(‘change’,function () {
var id_el = $(this).attr(‘id’);
alert(id_el);
});
• None of these.

77. Which of the following is the best method for adding options to a select from a JSON object using jQuery?
Answers:
• selectValues = { «1»: «test 1», «2»: «test 2» };
for (key in selectValues) {
if (typeof (selectValues[key] == ‘string’) {
$(‘#mySelect’).append(‘<option value=»‘ + key + ‘»>’ + selectValues[key] + ‘</option>’);
}
}
• $.each(selectValues, function(key, value) {
$(‘#mySelect’)
.append($(«<option></option>»)
.attr(«value»,key)
.text(value));
});
• $.each(selectValues, function(key, value) {
$(‘#mySelect’)
.append($(«<option>»)
.attr(«value»,key)
.text(value));
});
• $.each(selectValues, function(key, value) {
$(‘#mySelect’)
.append($(«<option>»)
.text(value));
});

78. Consider the following code snippet:
<div id=’id1′>
<div id=’id2′>Div 2</div>
</div>
Which of the following tags is/are in the result of $(‘#id2’).parents();?
Answers:
• html
• head
• body
>>>>>>>>>>>> • html and body
• head and body

79. Consider having multiple $(document).ready() functions in one or many linked javascript files. given this

information, which of the following will be executed?
Answers:
• first ready() function
• last ready() function
• All ready() functions
• None of them

80. Which of the following statements returns the number of matched elements of $(‘.class1’)?
Answers:
>>>>>>>>>> • $(‘.class1’).size();
• count($(‘.class1’));
• $(‘.class1’).count;
• None of these

81. How can jquery be used or optimized in such a way that the web applications can become richer and more

functional?
Answers:
• var DED = (function() { var private_var; function private_method() { // do stuff here } return { method_1 :

function() { // do stuff here }, method_2 : function() { // do stuff here } }; })();
• // file: survey.js $(document).ready(function() { var jS = $(‘#surveycontainer’); var jB =

$(‘#dimscreencontainer’); var d = new DimScreen({container: jB}); var s = new Survey({container: jS, DimScreen: d});

s.show(); });
• Exc.ui.domTips = function (dom, tips) { this.dom = gift; this.tips = tips; this.internal = { widthEstimates:

function (tips) { … } formatTips: function () { … } }; … };
• <script src=»jquery/1.3.2/jquery.js» type=»text/javascript»></script> <script type=»text/javascript»> var AcmeJQ =

jQuery.noConflict(true); var Acme = {fn: function(){}}; (function($){ Acme.sayHi = function() { console.log(‘Hello’);

}; Acme.sayBye = function() { console.log(‘Good Bye’); }; })(AcmeJQ); </script>

82. Is there a way to show custom exception messages as an alert in a jQuery Ajax error message?
Answers:
• jQuery.ajax({// just showing error property
error: function(jqXHR,error, errorThrown) {
if(jqXHR.status&&jqXHR.status==400){
alert(jqXHR.responseText);
}else{
alert(«Something went wrong»);
}
}
});
• $.ajax({
type: «post», url: «/SomeController/SomeAction»,
success: function (data, text) {
//…
},
error: function (request, status, error) {
alert(request.responseText);
}
});
• .error(function (response, q, t) {
var r = jQuery.parseJSON(response.responseText);
});
• jQuery.ajax({
type: «POST»,
url: «saveuser.do»,
dataType: «html»,
data: «userId=» + encodeURIComponent(trim(document.forms[0].userId.value)),
success: function (response) {
jQuery(«#usergrid»).trigger(«reloadGrid»);
clear();
alert(«Details saved successfully!!!»);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});

83. Consider the following code snippet:
<form id=»form1?>
<input type=»text» id=»text1? value=»default» />
<input type=»text» name=»email» />
</form>
<script type=»text/javascript»>
function submitForm1() {
alert($(‘#form1’).serialize());
}
</script>
What does the alert box display when the function submitForm1 is called?
Answers:
• email=
• email=&text1=default
• text1=&text2=
• Nothing is shown in the alert box.

84. Which of the following will make the background of a page change, upon being refreshed?
Answers:
>>>>>>>>>>>> • $(document).ready(function() {
var totalCount = 2;
Var num = Math.ceil( Math.random() * totalCount );
Document.body.background = ‘assets/background- ‘+num+’.jpg’;
});

• $(document).ready(function() {
var num = Math.ceil( Math.random() * totalCount );
Document.body.background = ‘assets/background- ‘+num+’.
});

• $(document).ready(function() {
var totalCount = 2;
Var num = Math( Math.random() * totalCount );
Document.body.background = ‘assets/background- ‘+num+’.jpg’;
});

• $(document).ready(function() {
var totalCount = 2;
Var num = Math( Math.ceil() * totalCount );
Document.body.background = ‘assets/background- ‘+num+’.jpg’;
});

85. Which of the following is the correct way to select all elements whose id contains string “test” using JQuery?
Answers:
• $(“[id*=’test’]”)
>>>>>>>>>> • $(“[id^=’test’]”)
• $(“id”).filter(“test”)
• $(“id”).find(“test”)

86. Which of the following selectors are not part of the CSS specification and therefore cannot take advantage of the

performance boost provided by the native DOM querySelectorAll() method?
Note: There may be more than one right answer.
Answers:
• :animated
• :checkbox
• .class
• :focus
• :image
• :last-child
• :nth-of-type()
• :visible

87. Which jQuery method should be used to deal with name conflicts?
Answers:
>>>>>>>>>> • noConflict()
• noNameConflict()
• nameConflict()
• conflict()

88. What will be the message in the alert box?
<div class=»selector»>Text mates</div>
<div class=»selector»>Text mates2</div>
alert(jQuery(‘.selector’).text().length);
Answers:
• 10
• NULL
>>>>>>>>>> • 21
• Text mates
Text mates2

89. Which of the following jQuery method can be used to make an ajax call?
Answers:
• ready(url, [data], [callback] )
>>>>>>>>>> • load( url, [data], [callback] )
• reload(url, [data], [callback] )
• None of the above.

90. Which of the following is the correct way to set the value of text area using jQuery?
Answers:
• $(«#textarea»).html(«value»);
• $(«#textarea»).text(«value»);
>>>>>>>>>> • $(«#textarea»).val(«value»);
• $(«#textarea»).attr(«value»);

91. Which jQuery function is used to prevent code from running, before the document is finished loading?
Answers:
• $(body).onload()
>>>>>>>>>> • $(document).ready()
• $(document).load()
• None of these

92. Which of the following jQuery method can be used to attach a function to be executed whenever AJAX request

completed successfully?
Answers:
• ajaxStart( callback )
>>>>>>>>>> • ajaxSuccess( callback )
• ajaxSend( callback )
• ajaxStop(callback)

93. Which of the following jQuery method gets the combined text contents of an element?
Answers:
• getText()
>>>>>>>>>> • text()
• getHtml()
• getContent()

94. How can an additional row be added to a table as the last row using jQuery?
Answers:
• $(‘#myTable tr:last’).after(‘<tr>…</tr><tr>…</tr>’);
• add_new_row(‘#myTable’,'<tr><td>my new row</td></tr>’);
>>>>>>>>> • $(‘#myTable > tbody:last’).append(‘<tr>…</tr><tr>…</tr>’);
• $(‘#myTable tr:end’).after(‘<tr>…</tr><tr>…</tr>’);

95. Which of the following jQuery selector selects element with the given element id some-id?
Answers:
• $(‘some-id’)
>>>>>>>>>>> • $(‘#some-id’)
• $(‘.some-id’)
• None of the above.

96. What is the difference between the two methods below of stopping event propagation?
1. event.preventDefault()
$(‘a’).click(function (e) {
// custom handling here
e.preventDefault();
});
2. return false
$(‘a’).click(function () {
// custom handling here
return false;
});
Answers:
• e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from

bubbling up and return false will do both.
• The benefit to using event.preventDefault() is that you can add this as the first line in the handler, thereby

guaranteeing that the anchor’s default behavior will not fire, regardless if the last line of the function is not

reached
• e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from

bubbling up.
• e.preventDefault() will prevent the all existing event from occuring, e.stopPropagation() will prevent the event

from bubbling up and return false will do both.

97. Which of the following jQuery method checks if event.preventDefault() was ever called on this event object?
Answers:
• isPropagationStopped( )
>>>>>>>>>> • isDefaultPrevented( )
• isImmediatePropagationStopped( )
• None of the above.

98. Which of the following is the correct way to move an element into another element?
Answers:
>>>>>>>>>> • $(‘#source’).prependTo(‘#destination’);
• $(«#source»).add(«#destination»);
• $(«#source»).html(«#destination»);
• $(«#source»).add().html().(«#destination»);

99. Which of the following is the correct way to hide a menu div by clicking outside the menu div?
Answers:
• $(‘html’).click(function() {
//Hide the menus if visible
});
$(‘#menucontainer’).click(function(event){
event.stopPropagation();
});
• $(‘#menucontainer’).click(function(event) {
$(‘body’).one(‘click’,function() {
// Hide the menus
});
event.stopPropagation();
});
>>>>>>>>>>> • $(document).click(function(event) {
if($(event.target).parents().index($(‘#menucontainer’)) == -1) {
if($(‘#menucontainer’).is(«:visible»)) {
$(‘#menucontainer’).hide()
}
}
})
• 4 down vote
$(document).click(function() {
$(«.overlay-window»).hide();
});
$(«.overlay-window»).click(function() {
return false;
});

100. How would you disable an HTML button element with id myButton?
Answers:
• $(‘#myButton’).prop(‘disabled’, true);
>>>>>>>>> • $(‘#myButton’).attr(‘disabled’)=true
• $(‘#myButton’).attr(‘disabled’);

101. Which of the following is the correct way to get HTML encoded value for any tag which function can be used?
Answers:
• function htmlEncode(value){
return $(‘<div/>’).text(value).html();
}
• function htmlEncode(value){
return $(‘<div/>’).html();
}
• function htmlEncode(value){
return $(‘<div/>’).text(value).val();
}
• function htmlEncode(value){
return $(‘<div/>’).innerHTML();
}

102. How would you check if an HTML element with an id of someElement exists in the DOM?
Answers:
• if ($(‘#someElement’).is(‘:visible’) == ‘true’)
>>>>>>>>>> • if ($(‘#someElement’).length)
• if ($(‘#someElement’).exists())

103. Which of the following is the correct way to get the value of a selected radio button from two radio buttons

with jQuery?
Answers:
• $(‘input[name=radioName]:checked’, ‘#myForm’).val()
• $(«form:radio:checked»).val();
>>>>>>>>>> • $(«input[name=’radioName’]:checked»).val()
• $(«form:radio:button:checked»).val();

104. what selection would you use to query for all elements with an id that ends with a particular string, for

example ‘txtTile’ ?
>>>>>>>>>> • $(“[id$=’txtTitle’]”)


105. which of the following jquery method gets a set of elements containing the closest parent element that matches

the specified selector, the stauting element included?

>>>>>>>>> • closest (selector)

106. which of the following are correct to chain your plugin?
note: there may be more than one right answer.

>>>>>>>>> •
>>>>>>>>> •

107. which of the following statements best describes the below code:
$(‘span.item’).each(function(index){
$(this).wrap(‘<p></p>’);
}
>>>>>>>>> • Wraps each span tag that has class item within a p tag.


108. select the fastest and most efficient way of hiding elements:

>>>>>>>>>> • $(‘#someElement’).find(‘p.someclass’).hide();

109. Which of the following statements returns all https anchor links?
>>>>>>>>>> • $(‘a[href^=https]’);
• $(‘a[href$=https]’);
• $(‘a[href=https]’);
• $(‘a[href]=https’);
$(‘#id1’).animate({width:”80%”}, “slow”)

110. Which of the following arguments is/are (a) valid argument(s) of fadeIn function?
• ‘slow’
• 1000ms
• 3000
• a and b
>>>>>>>>>> • a and c

111. What is divClick in the code snippet?
• An event type.
• An event function.
• A div class.
>>>>>>>>>> • A namespace

112. Which of the following functions can be used to attach event handler to an element?
>>>>>>>>>> • bind
• attach
• add
• handle

113. The hide() function hides an element by ————?
>>>>>>>>>> • setting “display” inline style attribute of that element to “none”.
• setting “visibility” inline style attribute of that element to “hidden”.
• setting the horizontal attribute of that element to “-100”.
• setting the vertical attribute of that element to “-100”.

114. is() function ——— the current selection against an expression?
>>>>>>>>>> • checks
• finds
• filters
• gets

115. Assume that you want that first the tag with “id1” fades out and then the tag with “id2” fades in. Which of the

following code snippets allow(s) you to do so?
• $(‘#id1’).fadeOut(‘fast’); $(‘#id2’).fadeIn(‘slow’);
• $(‘#id2’).fadeIn(‘slow’); $(‘#id1’).fadeOut(‘fast’);
>>>>>>>>>> • $(‘#id1’).fadeOut(‘fast’, function() {$(‘#id2’).fadeIn(‘slow’)});
• $(‘#id2’).fadeIn(‘slow’, function() {$(‘#id1’).fadeOut(‘fast’)});

116. If you include jQuery after other library, how do you disable the use of $ as a shortcut for jQuery?
>>>>>>>>>> • By calling jQuery.noConflict(); right after including jQuery.
• By calling jQuery.useDefault = false; right after including jQuery.
• By calling jQuery.useShortcut = false; right after including jQuery.
• By calling jQuery.conflict = false; right after including jQuery.

117. Consider the following code snippet:
var message = ‘Message’;
$(‘#id1’).bind(‘click’, {msg: message}, function(event) {
alert(event.data.msg);
});
message = ‘New message’;
$(‘#id2’).bind(‘click’, {msg: message}, function(event) {
alert(event.data.msg);
});

118. What does the alert box display if you click on “id1”?
>>>>>>>>>> • Message
• New message
• Nothing
• None of the above

119. Which of the following statements select(s) all option elements that are selected?
• $(‘:selected’);
• $(‘select[selected]’);
• $(‘option:selected’);
>>>>>>>>>> • a and c
• b and c

120. Inner Height function returns the inner height of an element, ——– the border and ——– the padding?
>>>>>>>>>> • excludes, includes
• excludes, excludes
• includes, excludes
• includes, includes

121. Which of the following statements return(s) a set of p tags that contain “jQuery”?
• $(‘p:contains(jQuery)’);
• $(‘p:contains(“jQuery”)’);
• $(‘p:has(“jQuery”)’);
>>>>>>>>>> • a and b
• a and c

122. jQuery allows you to use ——– function to switch between showing and hiding an element?
• show
• hide
• switch
>>>>>>>>>> • toggle

123. Which of the following functions can be used to bind an event handler to display a message when the window is

closed, reloaded or navigated to another page?
• end
• exit
>>>>>>>>>> • unload
• None of the above.

124. each is a generic ——- function.
>>>>>>>>>> • comparator
• operator
• iterator
• normal

125. $(‘ul#myId > li’);
What does the above statement return?
• A set of tags whose id is “li”.
• A set of tags which contains class “li”.
• A set of li tags which are children of ul tags that have “myId” class.
>>>>>>>>>> • A set of li tags which are children of ul tags that have “myId” id.

126. Which of the following commands creates a basic dialog containing this code snippet «font size=2»«div

id=”id1″»Simple dialog«/div»«/font» using jQuery UI?
>>>>>>>>>> • $(‘#id1).dialog();
• $(‘#id1).showDialog();
• $(‘#id1).widget();
• $(‘#id1).showWidget();

127. What is the result of this function jQuery.makeArray ( true )?
• 1
• NaN
• [ true ]
>>>>>>>>>> • []

128. What is the difference between $(‘p’).insertBefore(arg1) and $(‘p’).before(arg2) statement?
>>>>>>>>>> • The former inserts p tags before the tags specified by arg1, the latter inserts content specified by

arg2 before all p tags.
• The former inserts content specified by arg1 before p tags, the latter inserts p tags before tags specified by

arg2.
• The former inserts arg1 inside p tags, the latter inserts p tags inside tags specified by arg2.
• The former inserts p tags inside tags specified by arg1, the latter inserts arg2 inside p tags.

129. $.grep(array1, function1);
The above statement ——– the elements of array1 array which satisfy function1 function.
• sorts
• updates
• removes
>>>>>>>>>> • finds

129. Which of the following statements uses a valid selector?
• $(‘P’);
• $(‘#myId’);
• $(‘.myClass’);
>>>>>>>>>> • a, b and c
• b and c

130. Consider the following code snippet:
<font size=2>
<ul id=’id1′>
<li id=’li1′>Items 1</li>
<li id=’li2′>Items 2</li>
<li id=’li3′>Items 3</li>
</ul>
</font>

131. Which of the following code snippets return(s) a set of all li tags within “id1” except for li tag with id

“li2″?
>>>>>>>>>> • $(‘#id1 li’).not($(‘#li2’));
• $(‘#id1 li’).except($(‘#li2’));
• $(‘#id1 li’).remove($(‘#li2’));
• $(‘#id1 li’).delete($(‘#li2’));

132. Which of the following functions will return an empty set when end() function is chained right after that

function?
• add
• children
>>>>>>>>>> • filter
• remove

133. The outer height is returned by outerHeight function including ——- and ——- by default?
>>>>>>>>>> • border, padding
• border, margin
• margin, padding
• None of the above.

134. Which of the following values is/are valid argument(s) of eq() function?
>>>>>>>>>> • 1
• ‘2’
• both a and b
• neither a nor b

135. Which of the following methods can be used to delete a specified tag?
>>>>>>>>>> • remove.
• delete.
• truncate.
• empty.

136. Which of the following functions moves p tags that have para class to div with content id?
>>>>>>>>>> • function moveElement() {
$(‘p.para’).each(function(index) {
$(this).appendTo(‘#content’);
});
}
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).append(‘#content’);
});
}
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).insertAfter(‘#content’);
});
}
• function moveElement() {
$(‘p.para’).each(function(index) {
$(this).after(‘#content’);
});
}

137. Assume that you need to build a function that manipulates an image when the image is loaded. Which of the

following functions should you use?
• ready
>>>>>>>>>>> • load
• change
• focus

138. The css() function allows you to ———-?
• change the css class attribute.
• change the css file path.
• apply the css class to an element.
>>>>>>>>>>> • change the inline style attribute of an element.

139. What is the result of the following code snippet?
jQuery.unique([1, 2, 2, 3, 3, 1]);
• [1, 2, 3].
• [1, 2, 3, 1].
• [1, 3, 2, 1, 2, 3].
• [1, 1, 2, 2, 3, 3].
>>>>>>>>>>> • None of the above

140. Consider the following code snippet:
<ul id=’id1′>
<li id=’li1′>Items 1</li>
<li id=’li2′>Items 2</li>
<li id=’li3′>Items 3</li>
</ul>

141. Which of the following code snippets returns the same result as $(‘#id1 li’).not($(‘#li2’));?
>>>>>>>>>>> • $(‘#li2’).siblings();
• $(‘#id2’).siblings(‘#li2’);
• $(‘#li2’).children();
• $(‘#id2’).children(‘#li2’);

130. Is the following code snippet a valid ajax request?
$.ajax({data: {‘name’: ‘jQuery’},});
>>>>>>>>>>> • Yes.
• No, because it does not have url.
• No, because it does not have any argument after the comma.
• No, because the function ajax does not exist in jQuery.

142. Consider the following code snippet:
<form id=”form1″>
<input type=”text” id=”text1″ value=”default” />
<input type=”text” name=”email” />
</form>
<script type=”text/javascript”>
function submitForm1()
{
alert($(‘#form1’).serialize());
}
</script>

130. What does the alert box display when the function submitForm1 is called?
>>>>>>>>>>> • email=
• email=&text1=default
• text1=&text2=
• Nothing in the alert box.

143. Which of the following statements return(s) a set of even rows?
• $(‘tr’).filter(‘:even’);
• $(‘tr:nth-child(even)’);
• $(‘tr:odd’);
• a and b
>>>>>>>>>>> • b and c

144. One advantage of $.ajax function over $.get or $.post is that ———-?
>>>>>>>>>>> • $.ajax offers error callback option.
• $.ajax is easier to use.
• $.ajax allows passing request parameters.
• the result of $.ajax is formatted.

145. Consider the following code snippet:
$(‘#table1’).find(‘tr’).hide().slice(10, 20).show();
What is the result of this code snippet?
>>>>>>>>>>> • Showing table1’s rows from 11th to 20th.
• Showing table1’s 20 rows from 10th.
• Deleting rows of table1 from 10th to 20th.
• Deleting 20 rows of table1 from 10th onward.

146. Consider the following code snippet:
$(‘#div1’).html($(‘#div1’).html().replace(/bad/, ” “));
Which of the following is the result of this code snippet?
>>>>>>>>>>> • Replacing “bad” word in the inner html of div1.
• Removing any word containing “bad” in the inner html of div1.
• Appending an inner html of div1 which removes “bad” word to div1’s inner html.
• Appending an inner html of div1 which removes any word containing “bad” to div1’s inner html.

147. Which of the following methods can be used to copy element?
>>>>>>>>>>> • clone.
• cloneTo.
• move.
• moveTo.

148. Consider the following code snippet:
$(‘#table1 tr:odd’).addClass(‘oddRow’);
$(‘#table1 tr:even’).addClass(‘evenRow’);
The result of the above code snippet is ———-?
>>>>>>>>>>> • the odd rows of table1 have evenRow class, while the even rows have oddRow class
• the odd rows of table1 have oddRow class, while the even rows have evenRow class
• all rows of table1 have evenRow class
• None of the above.

149. Consider the following code snippet:
ajaxStart(function1);
The function1 will be executed when ———-?
• any ajax request starts.
• ajaxStart function is executed.
>>>>>>>>>>> • any ajax request starts and there is no active ajax request.
• jQuery does not have ajaxStart function.

150. position function gets the ——– positions of an element that are relative to its offset parent.
>>>>>>>>>>> • top and left
• top and right
• bottom and left
• bottom and right

151. Which of the following code snippets insert(s) the code snippet :
<div class=”footer”>footer</div> at the end of div tags?
>>>>>>>>>>> • $(‘div’).append(‘<div class=”footer”>footer</div>’);
• $(‘div’).appendTo(‘<div class=”footer”>footer</div>’);
• $(‘<div class=”footer”>footer</div>’).append(‘div’);
• $(‘<div class=”footer”>footer</div>’).appendTo(‘div’);

152. $.extend(false, object0, object1, object2);
What does the above do?
>>>>>>>>>>> • Extends the object0 by merging object1 and object2 with object0.
• Extends the object1 by merging object0 and object2 with object1.
• Extends the object2 by merging object0 and object1 with object2.
• The statement is invalid because its arguments are invalid.

153. Consider the following code snippet:
function function1() {
alert(arguments.length);
}
Which of the following is true when you run function1();?
• An error occurs because arguments variable is undefined.
• An error occurs because you call function1 with no arguments.
• The alert box displays “undefined”.
>>>>>>>>>>> • The alert box displays 0.

154. What does $(‘tr:nth-child(4)’) return?
>>>>>>>>>>> • A set of the fourth rows of the tables.
• A set of the fifth rows of the tables.
• A set of the fifth tr tags of the tables which have “nth-child(4)” class.
• A set of the fifth tr tags of the tables which have “nth-child(4)” id.

155. Is it true that we have to place the result of jQuery.getScript between <script type=”text/javascript”></script>

tags in order to use the loaded script?
• Yes.
>>>>>>>>>>> • No.

156. Which of the following commands creates a basic dialog containing this code snippet <div id=”id1″> Simple

dialog</div> using jQuery UI?
>>>>>>>>>>> • $(“#id1”).dialog();
• $(‘#id1).showDialog();
• $(‘#id1).widget();
• $(‘#id1).showWidget();

157. Which of the following seems to be correct for ajaxStart(function()) method as shown in the below Code snippet?
$(“#div1”).ajaxStart(function())
• Method Attaches a function to be executed before an Ajax request is sent.
• Method Attaches a function to be executed whenever an Ajax request completes successfully.
>>>>>>>>>>> • Method Attaches a function to be executed whenever an AJAX request begins and there is none already

activated.
• None of the above.

158. How can an Ajax Request that has not yet received the response, be canceled or aborted?
>>>>>>>>>>> • //xhr is ajax variable
xhr.abort()
• //xhr is ajax variable
xhr.cancel()
• //xhr is ajax variable
xhr.die()
• //xhr is ajax variable
xhr.destroy()

159. Which of the following is the correct way to get a Value of selected dropdownlist in jQuery without using the

selected value?
>>>>>>>>>>> • $(“#yourdropdownid option:selected”).text();
• $(“[id*=’MyDropDownId’] :selected”);
• $(“option:selected”, myVar).text()
• $(‘select[name=”thegivenname”] option:selected’).val();

160. Which of the following is the correct way to get the current URL in jQuery?
• var pathname = window.location.pathname;
>>>>>>>>>>> • $(location).attr(‘href’);
• $(location).value(‘href’);
• var pathname = window.location.routename;

161. Which of the following is the correct way to do the following javascript Code with jQuery?
var d = document; var odv = d.createElement(“div”); odv.style.display = “none”; this.OuterDiv = odv; var t =

d.createElement(“table”); t.cellSpacing = 0; t.className = “text”; odv.appendChild(t);
>>>>>>>>>>> • this.$OuterDiv = $(‘
‘)
.hide()
.append($(‘
‘)
.attr({ cellSpacing : 0 })
.addClass(“text”)
);
• var t = $(”
“);
$.append(t);
• $(‘
‘,{
text: ‘Div text’,
‘class’: ‘className’
}).appendTo(‘#parentDiv’);
• var userInput = window.prompt(“please enter selector”);
$(userInput).hide();

162. Which of the following is the correct way to select all the elements with JQuery from html that have the two

classes a and b?
>>>>>>>>>>> • $(‘.a.b’)
• $(‘.a, .b’)
• $(“.a”).filter(“.b”)
• a.b
{
style properties
}

163. Which of the following is the correct way to Hide menu div by clicking outside the menu div?
• $(‘html’).click(function() {
//Hide the menus if visible
});

$(‘#menucontainer’).click(function(event){
event.stopPropagation();
});
• $(‘#menucontainer’).click(function(event) {
$(‘body’).one(‘click’,function() {
// Hide the menus
});

event.stopPropagation();
});
>>>>>>>>>>> • $(document).click(function(event) {
if($(event.target).parents().index($(‘#menucontainer’)) == -1) {
if($(‘#menucontainer’).is(“:visible”)) {
$(‘#menucontainer’).hide()
}
}
})
• 4 down vote
$(document).click(function() {
$(“.overlay-window”).hide();
});
$(“.overlay-window”).click(function() {
return false;
});

164. which method is used to create custom animations in jquery?

>>>>>>>>>> • animate()

165. to wrap
text in element and give id as “title”?
>>>>>>>>>>> • $(“h1”).wrapinner(““);


166. which of the following correctly uses the replace() method ?

>>>>>>>>>> •

167. which of the following is the correct way to create an event and trigger it artifially?

>>>>>>>>> • var e =jquer.event(“click”);
jquery(“body”).call(e);

168. which of following is not a jquery utility method?
• $.trim()
• $.extend()
>>>>>>>>>> • $.ajax()

160. select the recommend way of calling multiple functions one after another on an element:


>>>>>>>>>> •

170. which is the correct method to remove a property for the set of methoed element?
>>>>>>>> • .removeProp();


171. what is the difference between the .position() and the .offset() method()

>>>>>>>>>> •

172. which of the following should be placed in the code below to alert data passed to event handler?
function myhandler(event){
// codde….
}
$(“#box”).on(“Click”, {foo: “bar”}, myhandler);
>>>>>>>>>> • alert(event.data.foo);


173. what does the method .one() do?
>>>>>>>>>> • attach a hendler to an event for the elements. the handler is executed at most once per element per event type.


174. which jquery method gets the current of the first matched element, in pixels, relative to the document?
>>>>>>>>> • offset()


175. what does the method jquery.getscript() do?

>>>>>>>>>>>> • load a javascript file from the server using a get http request, then execute it.

176. which of the following is/are correct to set the are attribute of an image?
>>>>>>>>>> •


177. what does the method .empty() do?

>>>>>>>>>> • remove all child nodes of the set of metached from the dom.

178. which jquery method retrieves all the elements contained in the jquery set, as an array?
>>>>>>>> • toArray()


One comment on “Upwork Jquery Skill Test 2018 Version

  1. Attractive section of content. I just stumbled upon your web site and in accession capital to assert that I acquire actually enjoyed account your blog posts. Anyway I’ll be subscribing to your feeds and even I achievement you access consistently rapidly.

Leave a Reply

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

*

*
*