Upwork Test Answers: Get all the correct answers of most recent and possible Upwork Tests A to Z (Updated on Jan, 2016)
Cover Letter Templates: These cover letter samples are not only for Upwork job, but also you will have some idea about your real life job
 
Freelance Profile Overviews: Different Profile samples and overviews of experts, advanced and intermediate level freelancers
For Newbie of Upwork: Upwork Help - How to apply for a job in Upwork with 10 most important articles about Upwork

A to Z View - All Upwork Test Answers

Upwork jQuery Test Answers

Here you will find all the Answers of the Upwork jQuery Test from Upwork Web Development category, please press CTRL + F to find your desired answer of the test questions.
--------------------------------------------------------------------------------------------------------------------

1. 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: • .second-row will slide up, then the targeted parent sibling .second-row will slide down.

 2. 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: • No

 3. Which of the following code snippets insert(s) the code snippet <font size=2><div class="footer">footer</div></font> at the end of div tags?
 Answers: • $('div').append('<div class="footer">footer</div>');

 4. jQuery allows you to use ___ function to switch between showing and hiding an element.
 Answers: • toggle

 5. What does $('tr.rowClass:eq(1)'); return?
 Answers: • One element set which is the second row of the first table.

 6. Which option can be used to have jQuery wait for all images to load before executing something on a page?
 Answers: • 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.

 7. offset function gets the current offset of the first matched element in pixels relative to the ___.
 Answers: • document

 8. 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: • The current div tag of the iteration.

 9. Which of the following returns the children tags of "id1"?
 Answers: • $('#id1').children();

 10. 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);


 11. 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: • Both the width animation and the height animation occur at the same time.

 12. What is the result of NaN == NaN?
 Answers: • false

 13. $("div").find("p").andSelf().addClass("border");
 The statement adds class border to ___.
 Answers: • all div tags and p tags in div tags

 14. $('#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.

 15. 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>
 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'));

 16. 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', function() {$('#id2').fadeIn('slow')});

 17. Which of the following methods can be used to copy element?
 Answers: • clone

 18. $('#id1').animate({width:"80%"}, "slow")

 The above code snippet will ___.
 Answers: • animate the tag with id1 from the current width to 80% width.

 19. 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'));

 20. Which of the following methods can be used to utilize the animate function with the backgroundColor style property?
 Answers: • Use the jQuery UI library.

 21. 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: • Both the width animation and the height animation occur at the same time.

 22. 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>');

 23. 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); }, async: false }); }

 24. 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 option[value='2']").text();

 25. 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();

 26. 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.

 27. Which of the following functions is/are built-in jQuery regular expression function(s)?
 Answers: • match

 28. each() is a generic ___ function.
 Answers: • iterator

 29. 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.

 30. 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, and function3

 31. 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"}); });

 32. Consider the following code snippet:
 $('#button1').bind('click', function(data) {...});
 What is the data argument?
 Answers: • Click event's data

 33. $("div").find("p").andSelf().addClass("border");

 The statement adds class border to ___.
 Answers: • all div tags and p tags in div tags

 34. 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>


 Which of the following code snippets return(s) a set of all li tags within "id1" except for li tag with id "li2"?
 Answers: • $('#id1 li').not($('#li2'));

 35. What is the result of this function: jQuery.makeArray ( true )?
 Answers: • [ true ]

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

 37. The hide() function hides an element by ___.
 Answers: • setting "display" inline style attribute of that element to "none".

 38. 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.

 39. One advantage of $.ajax function over $.get or $.post is that ___.
 Answers: • $.ajax offers error callback option.

 40. 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")

 41. Which of the following will get the first column of all tables using jQuery?
 Answers: • $('table.tblItemTemplate td:first-child');

 42. 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);

 43. 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();

 44. Which of the following is the correct way to disable an input field with jQuery?
 Answers: • $("input").attr('disabled','disabled');

 45. Which of the following functions can be used to stop event propagation?
 Answers: • stopPropagation

 46. How can the child img be selected inside the div with a selector?
 Answers: • jQuery(this).find("img");

 47. jQuery allows simulating an event to execute an event handler as if that event has just occurred by using ___.
 Answers: • trigger function

 48. Which of the following is the correct use of ajaxStart() function?
 Answers: • ajaxStart() function is used to run some code when ajax call start.

 49. The height function returns the height of an element in ___.
 Answers: • pixel units

 50. 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: • 3000

 51. Consider the following code snippet:


 $('#button1').bind('click', function(data) {...});


 What is the data argument?
 Answers: • Function's data

 52. Which of the following is the correct way to add an additional option and select it with jQuery?
 Answers: • $('#mySelect').append('<option value="whatever">text</option>').val('whatever')

 53. How can the href for a hyperlink be changed using jQuery?
 Answers: • $("a").attr("href", "http://www.google.com/");

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

 55. 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();

 56. 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!') }" })

 57. Which of the following events can be used to disable right click contextual menu?
 Answers: • contextmenu

 58. Which of the following gets the href attribute of "id1"?
 Answers: • $('#id1).attr('href');

 59. 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); } } });

 60. 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”).attr(); });

 61. What is the purpose of $(document).ready() function in Jquery?
 Answers: • To execute functions after DOM is loaded

 62. 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); } });

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

No comments:

Post a Comment