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:

  1. The targeted parent sibling .second-row will slide up, then .second-row will slide down.
  2. .second-row will slide up, then the targeted parent sibling .second-row will slide down.
  3. Both the targeted parent sibling .second-row will slide down and the .second-row will slide up actions will occur at the same time.
  4. None of the above.

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:

  1. Yes
  2. No
  3. “lastLi” does not exist.

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:

  1. $(‘div’).append(‘<div class=”footer”>footer</div>’);
  2. $(‘div’).appendTo(‘<div class=”footer”>footer</div>’);
  3. $(‘<div class=”footer”>footer</div>’).append(‘div’);
  4. $(‘<div class=”footer”>footer</div>’).appendTo(‘div’);

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

Answers:

  1. show
  2. hide
  3. switch
  4. toggle

5. What does $(‘tr.rowClass:eq(1)’); return?

Answers:

  1. One element set which is the second row of the first table.
  2. One element set which is the first row of the first table.
  3. A set of tr tags which have “rowClass:eq(1)” class .
  4. A set of tr tags which have “eq(1)” class .

6. Which option can be used to have jQuery wait for all images to load before executing something on a page?

Answers:

  1. All jQuery code need to add inside $function() { } syntax
  2. 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.
  3. With jQuery, can use $(document).ready() or $(window).load() syntax as these both are the same.
  4. $(window).onLoad(function() { })

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

Answers:

  1. document
  2. parent element
  3. children element
  4. container

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:

  1. window
  2. document
  3. The current div tag of the iteration.
  4. The last element tag in the body.

9. Which of the following returns the children tags of “id1”?

Answers:

  1. $(‘#id1’).children();
  2. $(‘#id1’).getChildren();
  3. children(‘#id1’);
  4. getChildren(‘#id1’);

10. Which of the following is the correct way to select an option based on its text in jQuery?

Answers:

  1. $(“#myselect option”).filter(function(){ return $(this).text() == ‘text’;}).prop(‘selected’, true);
  2. $(“#myselect option”).prop(‘selected’, true).text(“text”)
  3. $(“#myselect”).filter(“option”).prop(‘selected’, true).text(“text”);
  4. $(“#myselect”).filter(function(){ return $(this).val() == ‘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:

  1. First the width animation, then the height animation.
  2. First the height animation, then the width animation.
  3. Both the width animation and the height animation occur at the same time.
  4. The order of animations is random.

12. What is the result of NaN == NaN?

Answers:

  1. true
  2. false
  3. An error occurs.
  4. None of these.

13. $(“div”).find(“p”).andSelf().addClass(“border”);
The statement adds class border to ___.

Answers:

  1. all div tags and p tags in div tags
  2. all div tags
  3. all p tags
  4. all p tags enclosed in div tags

14. $(‘#a1’).one(‘click’, {times: 3}, function1);

Which of the following is true for the above?

Answers:

  1. function1 will be executed once regardless of the number of times a1 is clicked.
  2. function1 will be executed at most 3 times if a1 is clicked more than twice.
  3. There is at most one instance of function1 to be executed at a time.
  4. There are at most three instances of function1 to be executed at a time.

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:

  1. $(‘#id1 li’).not($(‘#li2’));
  2. $(‘#id1 li’).except($(‘#li2’));
  3. $(‘#id1 li’).remove($(‘#li2’));
  4. $(‘#id1 li’).delete($(‘#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:

  1. $(‘#id1’).fadeOut(‘fast’); $(‘#id2’).fadeIn(‘slow’);
  2. $(‘#id2’).fadeIn(‘slow’); $(‘#id1’).fadeOut(‘fast’);
  3. $(‘#id1’).fadeOut(‘fast’, function() {$(‘#id2’).fadeIn(‘slow’)});
  4. $(‘#id2’).fadeIn(‘slow’, function() {$(‘#id1’).fadeOut(‘fast’)});

17. Which of the following methods can be used to copy element?

Answers:

  1. clone
  2. cloneTo
  3. move
  4. moveTo

18. $(‘#id1’).animate({width:”80%”}, “slow”)

The above code snippet will ___.

Answers:

  1. animate the tag with id1 from the current width to 80% width.
  2. animate the tag with id1 from 80% width to current width.
  3. animate the tag with id1 from the current 80% width to 0px.
  4. animate the tag with id1 from 80% width to 100% 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:

  1. $(‘#id1 li’).not($(‘#li2’));
  2. $(‘#id1 li’).except($(‘#li2’));
  3. $(‘#id1 li’).remove($(‘#li2’));
  4. $(‘#id1 li’).delete($(‘#li2’));

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

Answers:

  1. Use the jQuery UI library.
  2. There is no need to do anything as jQuery core already supports that style property.
  3. There is no way to use animate with that style property.

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:

  1. First the width animation, then the height animation.
  2. First the height animation, then the width animation.
  3. Both the width animation and the height animation occur at the same time.
  4. The order of animations is random.

22. Which of the following code snippets insert(s) the code snippet
<div class=”footer”>footer</div>
at the end of div tags?

Answers:

  1. $(‘div’).append(‘<div class=”footer”>footer</div>’);
  2. $(‘div’).appendTo(‘<div class=”footer”>footer</div>’);
  3. $(‘<div class=”footer”>footer</div>’).append(‘div’);
  4. $(‘<div class=”footer”>footer</div>’).appendTo(‘div’);

23. Which option is correct to perform a synchronous AJAX request?

Answers:

  1. 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); } }); }
  2. 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) }); }
  3. 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 }); }
  4. jQuery only allow asynchronous AJAX request.

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:

  1. $(“#list[value=’2′]”).text();
  2. $(“#list option[value=’2′]”).text();
  3. $(this).find(“option:selected”).text();
  4. element.options[element.selectedIndex].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:

  1. $(‘#li2’).siblings();
  2. $(‘#id2’).siblings(‘#li2’);
  3. $(‘#li2’).children();
  4. $(‘#id2’).children(‘#li2’);

26. If jQuery is included before another library, how can conflict between jQuery and that library be avoided?

Answers:

  1. By calling jQuery.noConflict(); right after including jQuery.
  2. By calling jQuery.useDefault = false; right after including jQuery.
  3. By calling jQuery.useShortcut = false; right after including jQuery.
  4. By using the jQuery object when working with the jQuery library and using the $ object for other libraries.

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

Answers:

  1. test
  2. match
  3. find
  4. jQuery does not have built-in regular expression functions.

28. each() is a generic ___ function.

Answers:

  1. comparator
  2. operator
  3. iterator
  4. normal

29. Consider the following code snippet:
$(‘span.item’).each(function (index) {
$(this).wrap(‘<li>Item</li>’);
});
What does this code snippet do?

Answers:

  1. Wraps each span tag that has class item within a li tag.
  2. Inserts each span tag that has class item into a li tag.
  3. Inserts <li>Item</li> into each span that has item class.
  4. Replaces each span tag that has class item with a <li>Item</li>.

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:

  1. function1
  2. function2
  3. function3
  4. function1, function2, and function3
  5. No function is executed.

31. Which of the following represents the best way to make a custom right-click menu using jQuery?

Answers:

  1. $(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”}); });
  2. $(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”}); });
  3. $(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”}); });
  4. None of the above.

32. Consider the following code snippet:
$(‘#button1’).bind(‘click’, function(data) {…});
What is the data argument?

Answers:

  1. Click event’s data
  2. Function’s data
  3. Global variable
  4. Local variable

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

The statement adds class border to ___.

Answers:

  1. all div tags and p tags in div tags
  2. all div tags
  3. all p tags
  4. all p tags enclosed 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:

  1. $(‘#id1 li’).not($(‘#li2’));
  2. $(‘#id1 li’).except($(‘#li2’));
  3. $(‘#id1 li’).remove($(‘#li2’));
  4. $(‘#id1 li’).delete($(‘#li2’));

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

Answers:

  1. 1
  2. NaN
  3. [ true ]
  4. []

36. Which of the following is the correct way to get the value of a textbox using id in jQuery?

Answers:

  1. $(“.textbox”).text()
  2. $(“#textbox”).val()
  3. $(“.textbox”).val()
  4. $(“#textbox”).text()

37. The hide() function hides an element by ___.

Answers:

  1. setting “display” inline style attribute of that element to “none”.
  2. setting “visibility” inline style attribute of that element to “hidden”.
  3. setting the horizontal attribute of that element to “-100”.
  4. setting the vertical attribute of that element to “-100”.

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:

  1. The rows of table1 at order 3n + 1 (n = 0, 1, 2,…) will belong to the class firstRowClass.
  2. The rows of table1 at order 3n (n = 1, 2,…) will belong to the class firstRowClass.
  3. All rows of table1 will belong to the class firstRowClass.
  4. No row of table1 will belong to the class firstRowClass.

39. One advantage of $.ajax function over $.get or $.post is that ___.

Answers:

  1. $.ajax offers error callback option.
  2. $.ajax is easier to use.
  3. $.ajax allows passing request parameters.
  4. the result of $.ajax is formatted.

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:

  1. $(element).is(“:visible”)
  2. $(this).css(“visibility”) == “hidden”
  3. $(element).is(“:invisible”)
  4. $(this).css(“visibile”) == “hidden”

41. Which of the following will get the first column of all tables using jQuery?

Answers:

  1. $(‘table.tblItemTemplate first-child’);
  2. $(‘table.tblItemTemplate tr:first-child’);
  3. $(‘table.tblItemTemplate td:first-child’);
  4. $(‘tabletblItemTemplate 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:

  1. $(‘#elem’).selectRange(3,5);
  2. $(‘#elem’).selectRange(3 5);
  3. $(‘#elem’).selectRange(X:3,Y:5);
  4. $(‘#elem’).fn.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:

  1. $(‘#list1’).sortable();
  2. $(‘#list1’).changeable();
  3. $(‘#list1’).interchangeable();
  4. $(‘#list1’).organizeable();

44. Which of the following is the correct way to disable an input field with jQuery?

Answers:

  1. $(“input”).attr(‘disabled’,’disabled’);
  2. $(“input”).css(‘disabled’,’disabled’);
  3. $(“input”).attr(‘disable’,’disable’);
  4. $(“input”).(‘disabled’);

45. Which of the following functions can be used to stop event propagation?

Answers:

  1. stopPropagation
  2. disablePropagation
  3. cancelPropagation
  4. preventPropagation

46. How can the child img be selected inside the div with a selector?

Answers:

  1. jQuery(this).children(“img”);
  2. jQuery(this).find(“img”);
  3. $(this).find(“img”).attr(“alt”)
  4. $(this).children(“img”).attr(“alt”)

47. jQuery allows simulating an event to execute an event handler as if that event has just occurred by using ___.

Answers:

  1. trigger function
  2. execute function
  3. intimate function
  4. jQuery does not have this feature.

48. Which of the following is the correct use of ajaxStart() function?

Answers:

  1. ajaxStart() function is used to start ajax call.
  2. ajaxStart() function is used to run some code when ajax call start.
  3. a & b
  4. None of the above.

49. The height function returns the height of an element in ___.

Answers:

  1. pixel units
  2. point units
  3. em units
  4. millimeter 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:

  1. ‘fast’
  2. slow
  3. 1000ms
  4. 3000

51. Consider the following code snippet:
$(‘#button1’).bind(‘click’, function(data) {…});
What is the data argument?

Answers:

  1. Click event’s data
  2. Function’s data
  3. Global variable
  4. Local variable

52. Which of the following is the correct way to add an additional option and select it with jQuery?

Answers:

  1. $(‘#mySelect’).append(‘<option value=”whatever”>text</option>’).val(‘whatever’)
  2. $(‘#mySelect’).html(‘<option value=”whatever”>text</option>’).val(‘whatever’)
  3. $(‘#mySelect’).text(‘<option value=”whatever”>text</option>’).val(‘whatever’)
  4. $(‘#mySelect’).val(‘whatever’)

53. How can the href for a hyperlink be changed using jQuery?

Answers:

  1. $(“a”).link(“http://www.google.com/”);
  2. $(“a”).change(“href”,”http://www.google.com/”);
  3. $(“a”).link(“href”,”http://www.google.com/”);
  4. $(“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:

  1. top and left
  2. top and right
  3. bottom and left
  4. bottom and right

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:

  1. $(‘#li2’).siblings();
  2. $(‘#id2’).siblings(‘#li2’);
  3. $(‘#li2’).children();
  4. $(‘#id2’).children(‘#li2’);

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

Answers:

  1. var clickEvents = $(‘#foo’).data(“events”).click; jQuery.each(clickEvents, function(key, value) { console.log(value) // prints “function() { console.log(‘clicked!’) }” })
  2. $.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 ); }); } }); }); };
  3. var clickEvents = $(‘#foo’).data(“events”).click; jQuery.each(clickEvents, function(key, value) { event.console.log(value); })
  4. $.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 ); }); } }); }); };

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

Answers:

  1. contextmenu
  2. contextualmenu
  3. rightclickmenu
  4. The right-click contextual menu cannot be disabled.

58. Which of the following gets the href attribute of “id1”?

Answers:

  1. $(‘#id1).attr(‘href’);
  2. $(‘#id1’).getAttribute(‘href’);
  3. $(‘#id1)[0].attr(‘href’);
  4. All of these.

59. Which of the following is the correct way to manage a redirect request after a jQuery Ajax call?

Answers:

  1. $.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); } } });
  2. public ActionResult Index(){ if (!HttpContext.User.Identity.IsAuthenticated) { HttpContext.Response.AddHeader(“REQUIRES_AUTH”,”1″); } return View() }
  3. $.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(); } });
  4. $(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 ); }; }); });

60. Which of the following is the correct way to change the image source during click event of a button in jQuery?

Answers:

  1. $(“#button”).click(function(){ $(“img”).src(); });
  2. $(“#button”).click(function(){$(“img”).attr(); });
  3. $(“#button”).submit(function(){$(“img”).text();});
  4. $(“#button”).submit(function(){$(“img”).html(); });

61. What is the purpose of $(document).ready() function in Jquery?

Answers:

  1. To execute functions after all content and images are loaded
  2. To execute functions after DOM is loaded
  3. To execute functions before DOM load
  4. To execute functions before content and images load

62. Which of the following will show an alert containing the content(s) of a database selection?

Answers:

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

63. How can an Ajax request that has not yet received a response be canceled or aborted?

Answers:

  1. //xhr is an Ajax variable xhr.abort()
  2. //xhr is an Ajax variable xhr.cancel()
  3. //xhr is an Ajax variable xhr.die()
  4. //xhr is an Ajax variable xhr.destroy()

64.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:

  1. The rows of table1 at order 3n + 1 (n = 0, 1, 2,…) will belong to the class firstRowClass.
  2. The rows of table1 at order 3n (n = 1, 2,…) will belong to the class firstRowClass.
  3. All rows of table1 will belong to the class firstRowClass.
  4. No row of table1 will belong to the class firstRowClass.

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

Answers:

  1. add
  2. children
  3. filter
  4. remove

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

Answers:

  1. add
  2. children
  3. filter
  4. remove

67.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:

  1. Message
  2. New message
  3. Nothing
  4. None of these

68.Which of the following is correct with regards to how to upload a file asynchronously with jQuery?

Answers:

  1. 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).
  2. $(‘#one-specific-file’).ajaxfileupload({
    ‘action’: ‘/upload.php’
    });
  3. Ajax file uploads cannot be done.
  4. $(document).ready(function() {
    $(«#uploadbutton»).jsupload({
    action: «addFile.do»,
    onComplete: function(response){
    alert( «server response: » + response);
    }
    });

68.Consider the following code snippet:
$.map(array1, function1);
Which of the following arguments is/are valid arguments of function1?

Answers:

  1. The index of the element to be translated in array1.
  2. The item to be translated.
  3. function1 has no arguments.
  4. Both the index of the element to be translated in array1 and the item to be translated.

69.Which of the following is the correct way to distinguish left and right mouse click event in jQuery

Answers:

  1. event.what
  2. event.which
  3. event.click
  4. event.whichclick

70. Which of the following will select a particular option in a <select> element using its index?

Answers:

  1. $(‘select option[value=»1″]’)
  2. $(‘select option:eq(1)’)
  3. $(‘select option:contains(«Selection 1»)’)
  4. All of the above.

71. $.merge(array1, array2);
The above function merges ___.

Answers:

  1. array1 into array2.
  2. array2 into array1.
  3. array1 with array2 and returns the result.
  4. The statement is invalid. The correct one is array1.merge(array2);

72. Which of the following makes use of jQuery to select multiple elements?

Answers:

  1. $(‘table td’).eq([0, 5, 9])
  2. $(‘table td:eq(0), table td:eq(5), table td:eq(9)’)
  3. $(‘table td’).eqAny([1, 5, 9]);
  4. None of these.

73. Whats the right way to access the contents of an iframe using jQuery?

Answers:

  1. If the <iframe> is from the same domain, the elements are easily accessible as
    $(«#iFrame»).contents().find(«#someDiv»).removeClass(«hidden»);
  2. $(‘#frametest’).HTML()
  3. $(‘some selector’, frames[‘nameOfMyIframe’].document).innerHTML()
  4. All of Above

74. Which of the following is the correct way to select <a> on the basis of href using jQuery?

Answers:

  1. jQuery(«a»).href()
  2. jQuery(«a»).attr(«href»)
  3. jQuery(«a[href=’url’]»)
  4. jQuery(«a attr[href=’url’]»)

75. Which of the following values is/are valid argument(s) of the eq() function?

Answers:

  1. 1
  2. ‘2’
  3. Both 1 and ‘2’.
  4. Neither 1 nor ‘2’

76. 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:

  1. jQuery.fn.exists = function(){return this.length>0;}
    if ($(selector).exists()) {
    // Do something
    }
  2. jQuery.fn = function(){return this.length>0;}
    if ($(selector).exists()) {
    // Do something
    }
  3. jQuery.exists = function(selector) {return ($(selector).length > 0);}
    if ($.exists(selector)) { }
  4. NjQuery.fn.exists = function(selector) {
    return selector ? this.find(selector).length : this.length;
    };

77. Which of the following methods can be used to load data?

Answers:

  1. getJSON.
  2. get.
  3. ajaxSend.
  4. ajaxStart.

78. What is the difference between jQuery’s .focusout() and .blur() events?

Answers:

  1. 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.
  2. 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.
  3. There is no difference between the .focusout() and .blur() events; the two can be used interchangeably.
  4. None of the above.

79. Which of the following is the correct way to assign a selected value of a drop-down list

Answers:

  1. T$(«#myDDL»).val(2);
  2. T$(«.myDDL»).children(«option»).val(2);
  3. $(«.myDDL»).val(‘2’);
  4. $(«.myDDL»).children(«option»).innerText(‘2’);

80. How or where can a plugin be declared, so that the plugin methods are available for the script?

Answers:

  1. In the head of the document, include the plugin after main jQuery source file, before the script file.
  2. In the head of the document, include the plugin after all other script tags
  3. In the head of the document, include the plugin before all other script tags.
  4. Anywhere in the document.

81. Which of the following is the best way to open a jQuery UI dialog box without a title bar?

Answers:

  1. $(«#ui-dialog-titlebar»).hide();
  2. $(«.ui-dialog-titlebar»).hide();
  3. $(«#dialog»).siblings(‘div#ui-dialog-titlebar’).remove();
  4. $(«.ui-titlebar»).hide();

82. Which of the following functions moves p tags that have para class to div with content id?

Answers:

  1. function moveElement() {
    $(‘p.para’).each(function(index) {
    $(this).appendTo(‘#content’);
    });
    }
  2. function moveElement() {
    $(‘p.para’).each(function(index) {
    $(this).append(‘#content’);
    });
    }
  3. function moveElement() {
    $(‘p.para’).each(function(index) {
    $(this).insertAfter(‘#content’);
    });
    }
  4. function moveElement() {
    $(‘p.para’).each(function(index) {
    $(this).after(‘#content’);
    });
    }

83. Which of the following will detect a change in the value of a hidden input?

Answers:

  1. $(‘#id_inpout’).live(‘change’,function () {
    var id_el = $(this).attr(‘id’);
    alert(id_el);
    });

  2. $(‘#id_inpout’).change(function () {
    var id_el = $(this).attr(‘id’);
    alert(id_el);
    });

  3. $(‘#id_inpout’).bind(‘change’,function () {
    var id_el = $(this).attr(‘id’);
    alert(id_el);
    });

  4. None of these.

84. Which of the following is the best method for adding options to a select from a JSON object using jQuery?

Answers:

  1. selectValues = { «1»: «test 1», «2»: «test 2» };
    for (key in selectValues) {
    if (typeof (selectValues[key] == ‘string’) {
    $(‘#mySelect’).append(‘<option value=»‘ + key + ‘»>’ + selectValues[key] + ‘</option>’);
    }
    }

  2. $.each(selectValues, function(key, value) {
    $(‘#mySelect’)
    .append($(«<option></option>»)
    .attr(«value»,key)
    .text(value));
    });

  3. $.each(selectValues, function(key, value) {
    $(‘#mySelect’)
    .append($(«<option>»)
    .attr(«value»,key)
    .text(value));
    });

  4. $.each(selectValues, function(key, value) {
    $(‘#mySelect’)
    .append($(«<option>»)
    .text(value));
    });

85. 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:

  1. html
  2. head
  3. body
  4. html and body
  5. head and body

86. Consider having multiple $(document).ready() functions in one or many linked javascript files. given this information, which of the following will be executed?

Answers:

  1. first ready() function
  2. last ready() function
  3. All ready() functions
  4. html and body
  5. None of them

87. Which of the following statements returns the number of matched elements of $(‘.class1’)?

Answers:

  1. $(‘.class1’).size();
  2. count($(‘.class1’));
  3. $(‘.class1’).count;
  4. None of these

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

Answers:

  1. 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 } }; })();
  2. // 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(); });
  3. Exc.ui.domTips = function (dom, tips) { this.dom = gift; this.tips = tips; this.internal = { widthEstimates: function (tips) { … } formatTips: function () { … } }; … };
  4. <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>

89. Is there a way to show custom exception messages as an alert in a jQuery Ajax error message?

Answers:

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

  2. $.ajax({
    type: «post», url: «/SomeController/SomeAction»,
    success: function (data, text) {
    //…
    },
    error: function (request, status, error) {
    alert(request.responseText);
    }
    });
  3. .error(function (response, q, t) {
    var r = jQuery.parseJSON(response.responseText);
    });
  4. 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);
    }
    });

90. 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:

  1. email=
  2. email=&text1=default
  3. .text1=&text2=
  4. Nothing is shown in the alert box.

91. Which of the following will make the background of a page change, upon being refreshed?

Answers:

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

92. Which of the following is the correct way to select all elements whose id contains string “test” using JQuery?

Answers:

  1. $(“[id*=’test’]”)
  2. $(“[id^=’test’]”)
  3. $(“id”).filter(“test”)
  4. $(“id”).find(“test”)

93.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?

Answers:

  1. :animated
  2. :checkbox
  3. class
  4. :focus
  5. :image
  6. :nth-of-type()
  7. :visible

93. Which jQuery method should be used to deal with name conflicts?

Answers:

  1. noConflict()
  2. noNameConflict()
  3. nameConflict()
  4. conflict()

94. 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:

  1. 10
  2. NULL
  3. 21
  4. Text mates
  5. Text mates2

95. Which of the following jQuery method can be used to make an ajax call?
<div class=»selector»>Text mates</div>
<div class=»selector»>Text mates2</div>
alert(jQuery(‘.selector’).text().length);

Answers:

  1. ready(url, [data], [callback] )
  2. load( url, [data], [callback] )
  3. reload(url, [data], [callback] )
  4. None of the above.

96. Which of the following is the correct way to set the value of text area using jQuery?
<div class=»selector»>Text mates</div>
<div class=»selector»>Text mates2</div>
alert(jQuery(‘.selector’).text().length);

Answers:

  1. $(«#textarea»).html(«value»);
  2. $(«#textarea»).text(«value»);
  3. $(«#textarea»).val(«value»);
  4. $(«#textarea»).attr(«value»);

97. Which jQuery function is used to prevent code from running, before the document is finished loading?

Answers:

  1. $(body).onload()
  2. $(document).ready()
  3. $(document).load()
  4. None of these

98. Which of the following jQuery method can be used to attach a function to be executed whenever AJAX request completed successfully?

Answers:

  1. ajaxStart( callback )
  2. ajaxSuccess( callback )
  3. ajaxSend( callback )
  4. ajaxStop(callback)

99.Which of the following jQuery method gets the combined text contents of an element?

Answers:

  1. getText()
  2. text()
  3. getHtml()
  4. getContent()

100. How can an additional row be added to a table as the last row using jQuery?

Answers:

  1. $(‘#myTable tr:last’).after(‘
    … …

    ’);

  2. add_new_row(‘#myTable’,’
    my new row

    ’);

  3. $(‘#myTable > tbody:last’).append(‘
    … …

    ’);

  4. $(‘#myTable tr:end’).after(‘
    … …

    ’);

101. Which of the following jQuery selector selects element with the given element id some-id?

Answers:

  1. $(‘some-id’)
  2. $(‘#some-id’)
  3. $(‘.some-id’)
  4. None of the above.

102. What is the difference between the two methods below of stopping event propagation?

Answers:

  1. event.preventDefault()
    $(‘a’).click(function (e) {
    // custom handling here
    e.preventDefault();
    });

  2. return false
    $(‘a’).click(function () {
    // custom handling here
    return false;
    });
  3. e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up and return false will do both.
  4. 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
  5. e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up.
  6. 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.

103. Which of the following jQuery method checks if event.preventDefault() was ever called on this event object?

Answers:

  1. isPropagationStopped( )
  2. isDefaultPrevented( )
  3. isImmediatePropagationStopped( )
  4. None of the above.

104. Which of the following is the correct way to move an element into another element?

Answers:

  1. $(‘#source’).prependTo(‘#destination’);
  2. $(«#source»).add(«#destination»);
  3. $(«#source»).html(«#destination»);
  4. $(«#source»).add().html().(«#destination»);

105. Which of the following is the correct way to hide a menu div by clicking outside the menu div?

Answers:

  1. $(‘html’).click(function() {
    //Hide the menus if visible
    });
    $(‘#menucontainer’).click(function(event){
    event.stopPropagation();
    });
  2. $(‘#menucontainer’).click(function(event) {
    $(‘body’).one(‘click’,function() {
    // Hide the menus
    });
    event.stopPropagation();
    });
  3. $(document).click(function(event) {
    if($(event.target).parents().index($(‘#menucontainer’)) == -1) {
    if($(‘#menucontainer’).is(«:visible»)) {
    $(‘#menucontainer’).hide()
    }
    }
    })
  4. $4 down vote
    $(document).click(function() {
    $(«.overlay-window»).hide();
    });
    $(«.overlay-window»).click(function() {
    return false;
    });

106. How would you disable an HTML button element with id myButton?

Answers:

  1. $(‘#myButton’).prop(‘disabled’, true);
  2. $(‘#myButton’).attr(‘disabled’)=true
  3. $(‘#myButton’).attr(‘disabled’);

107. Which of the following is the correct way to get HTML encoded value for any tag which function can be used?

Answers:

  1. function htmlEncode(value){
    return $(‘<div/>’).text(value).html();
    }

  2. function htmlEncode(value){
    return $(‘<div>>’).html();
    }
  3. function htmlEncode(value){
    return $(‘<div/>’).text(value).val();
    }
  4. function htmlEncode(value){
    return $(‘<div/>’).innerHTML();
    }

108. How would you check if an HTML element with an id of someElement exists in the DOM?

Answers:

  1. if ($(‘#someElement’).is(‘:visible’) == ‘true’)
  2. if ($(‘#someElement’).length)
  3. if ($(‘#someElement’).exists())

109. Which of the following is the correct way to get the value of a selected radio button from two radio buttons with jQuery?

Answers:

  1. $(‘input[name=radioName]:checked’, ‘#myForm’).val()
  2. $(«form:radio:checked»).val();
  3. $(«input[name=’radioName’]:checked»).val()
  4. $(«form:radio:button:checked»).val();

1,642 total views, 2 views today