This jQuery quiz (Questions 11-20) tests your knowledge of this popular JavaScript library. Corrections are welcome!
Key Concepts Covered: This quiz assesses your understanding of jQuery's event handling, function execution, element selection, class manipulation, DOM traversal, and code interpretation.
Question 11: How do you determine which key was pressed using jQuery?
A. $('#txtValue').keypress(function (event) { $('#txtvalue').alert((event.keyCode)); });
B. $(‘#txtValue’).keypress(function (event) { alert(String.fromCharCode((event.keyCode))); });
C. $(‘#txtValue’).keypress(function (event) { alert(fromCharCode((event.keyCode))); });
D. $(‘#txtValue’).keypress(function (event) { $(‘#txtvalue’).alert((event.which)); });
Correct Answer: D
API Reference: https://www.php.cn/link/2d2c18c1aaeac9fcc028dd14f4c074ce
Question 12: Given this code: $('#ul1 li').on('click', function1); $('#ul1').after('<li id="lastLi">Last item</li>');
Will function1
execute if "lastLi" is clicked?
A. Yes B. No
Correct Answer: B
Question 13: What does $("ul#myId > li");
return?
A. Tags with id "li".
B. Tags with class "li".
C. li
tags that are children of a ul
with class "myId".
D. li
tags that are children of a ul
with id "myId".
Correct Answer: D
Question 14: What's the result of $('#table1').find('tr').filter(function (index) { return index % 3 == 0 }).addClass('firstRowClass');
?
A. Rows at index 3n 1 (n = 0, 1, 2…) get the class. B. Rows at index 3n (n = 1, 2…) get the class. C. All rows get the class. D. No rows get the class.
Correct Answer: A (See this in action: https://www.php.cn/link/70522cd467f1001ad2c2d009707f61d9)
Question 15: How do you move an element into another?
A. $('#source').prependTo('#destination');
B. $("#source").add("#destination");
C. $("#source").html("#destination");
D. $("#source").add().html().("#destination");
Correct Answer: A
Question 16: What does $('span.item').each(function (index) { $(this).wrap('<li>'); });</li>
do?
A. Wraps each span with class "item" in a <li>
.
B. Inserts each span with class "item" into a <li>
.
C. Inserts "Item" into each span with class "item".
D. Replaces each span with class "item" with "Item".
Correct Answer: A (See this in action: https://www.php.cn/link/0f0e0ddd3be45a94e4941c890a8ed1d1)
Question 17: What's the result of jQuery.unique([1, 2, 2, 3, 3, 1]);
?
A. [1, 2, 3]
B. [3, 2, 1]
C. [1, 1, 2, 2, 3, 3]
D. None of the above
Correct Answer: A (See this in action: https://www.php.cn/link/b050b09d2d80bdc271a775f5b4639258)
Question 18: What's the result of $('#table1').find('tr').hide().slice(10, 20).show();
?
A. Shows rows 11-20 of table1
.
B. Shows 20 rows starting from the 10th of table1
.
C. Deletes rows 10-20 of table1
.
D. Deletes 20 rows starting from the 10th of table1
.
Correct Answer: A (See this in action: https://www.php.cn/link/17440cbf2d556ce0c945559586426aaa)
Question 19: $("div").find("p").andSelf().addClass("border");
adds the "border" class to:
A. All Correct Answer: B (See this in action: https://www.php.cn/link/ffdc7fa7222f38cac5455d928f2b021b) Question 20: Which statement(s) return A. 1 and 2
B. 1 and 3
C. 2 and 3
D. 1, 2, and 3 Correct Answer: A (See this in action: https://www.php.cn/link/c064251d2c99adbee465c50f05bda944) (FAQs section omitted for brevity as it's largely explanatory and not requiring rewriting for originality.)<code><p></p>
tags inside <code><p></p>
tags inside <code><p></p>
tags.
<code><p></p>
tags containing "jQuery"?
<li>
$('p:contains(jQuery)');
<li>$('p:contains("jQuery")');
<li>$('p:has("jQuery")');
The above is the detailed content of jQuery Quiz Questions 11-20. For more information, please follow other related articles on the PHP Chinese website!