You are implementing an application by using HTML5 and JavaScript. A web page contains
the following HTML table.
The application must:
Identify all rows in the table body that have a class attribute of selected
Exclude the last selected row in the table
You need to implement the web page according to the requirements.
Which CSS selector should you use?
A.
tr:not(tr:last-child).selected < #dataTable
B.
#dataTable > tr.selected:not(tr:last-child)
C.
#dataTable tbody tr.selected:not(tr:last-child)
D.
#dataTable tr.selected:not(tr:last-child)
What is this question exactly about? They’re asking to exclude last .selected row in tbody or last .selected row in table? If it’s the first option, then answer C is correct. But if it’s the second – then D is correct.
Identify all rows in the table body that have a class attribute of selected.
Its clear in the question that table body should be considered. So, Option C is correct.
it should be
table tbody tr.selected:not(:last-child)
Explanation/Reference:
* [attribute]
[target]
Selects all elements with a target attribute
* :not(selector)
not(p)
Selects every element that is not a element
Reference: CSS Selector Reference