jQuery Quiz Questions 21-30

Share this article

Following on from jQuery Quiz Questions 11-20 here are questions 21-30. Hopefully you might learn something new about jQuery you didn’t know before. Once more if you find any mistakes please feel free to leave a comment with corrections. Enjoy!

Question 21

Which of the following values is/are valid value(s) of secondArgument in addClass(‘turnRed’, secondArgument); function, if we use jQuery UI library?

Answers

  • ‘fast’
  • slow
  • 1000ms
  • ‘1000ms’
  • 3000

Correct Answers

  • ‘fast’
  • ‘1000ms’
  • 3000

 


Question 22

is() function ___ the current selection against an expression.

Answers

  • checks
  • filters
  • gets
  • converts

Correct Answer
checks
API: http://api.jquery.com/is

 


Question 23

What does $('tr.rowClass:eq(1)'); return?

Answers

  • One element set which is the first row of the first table.
  • One element set which is the second 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.

Correct Answer
One element set which is the second row of the first table.
see answer in action: https://jsfiddle.net/jquery4u/EHbJq/3/

 


Question 24

innerHeight function returns the inner height of an element, ___ the border, ___ the margin and ___ the padding.

Answers

  • excludes, excludes, excludes
  • includes, excludes, includes
  • excludes, excludes, includes
  • includes, includes, includes

Correct Answer
excludes, excludes, includes
API: http://api.jquery.com/innerHeight/

 


Question 25

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

What does the alert box display if you click on “id1”?

Answers

  • Message
  • New Message
  • nothing
  • None of the above

Correct Answer
Message
see answer in action: https://jsfiddle.net/jquery4u/fhaDf/

 


Question 26

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

Answers

  • add
  • children
  • filter
  • remove

Correct Answer
remove
.remove() returns jQuery(document) which is classed as an empty set.
see answer in action: https://jsfiddle.net/jquery4u/bScnP/

 


Question 27

Which of the following seems to be correct for ajaxStart(function()) method as shown in the below Code?

$("#div1").ajaxStart(function1());

Answers

  • Method attaches a function to be executed before an Ajax request is sent.
  • Method attaches a function to be executed whenever any Ajax request begins.
  • Method attaches a function to be executed whenever an Ajax request begins and there is none already activated.
  • None of the above.

Correct Answer
Method attaches a function to be executed whenever an Ajax request begins and there is none already activated.
API: http://api.jquery.com/ajaxStart/

 


Question 28

Consider the following code snippet:

$('#div1').html().replace(/bad/, "good");

Answers

  • Replacing the “bad” word in the inner html of div1 with “good”.
  • Replacing the word containing “bad” in the inner html of div1 with “good”.
  • Replacing the first “bad” word in the inner html of div1 with “good”.
  • Replacing the first word containing “bad” in the inner html of div1 with “good”.

Correct Answer
Replacing the first word containing “bad” in the inner html of div1 with “good”.
see answer in action: https://jsfiddle.net/jquery4u/95Kv8/1/

 


Question 29

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.
  • Both a and b
  • function1 has no arguments.

Correct Answer
Both a and b
API: http://api.jquery.com/jquery.map/

 


Question 30

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

Answers

  • 1
  • ‘2’
  • -1

Correct Answer
all of them.
see answer in action: https://jsfiddle.net/jquery4u/EBcqN/2/
API: http://api.jquery.com/eq/

 


Sam DeeringSam Deering
View Author

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

jQuery
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week