You develop an HTML5 webpage that contains the following HTML markup:
You have the following requirements:
Retrieve the content for any OPTION elements when the value of the selected attribute equals selected.
Add the content to a comma separated string.
You need to retrieve the required data.
Which two code segments should you add to the webpage? (Each correct answer presents a complete solution. Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Explanation:
Note:
* select option:selected
:selected Selector
Description: Selects all elements that are selected.
Correct answer is C & D
20
0
I agree. I just wanted to add that the only reason why C & D are correct is $(this) selector which points to selected options in .each() function and not to parent select element.
It means that:
* :checked is totally fine and would work exactly the same as :selected;
* $(loanTypes) selector points to wrong element but semantically is correct for IDs, which means that it is not an error that “”/” are missing here;
2
0