Selectors API support in Opera Presto 2.9

W3C reference
Selectors API Level 1

Opera Presto provides support for the Selectors API Level 1.

NodeSelector interface

The NodeSelector interface is implemented by objects implmenting the following interfaces:

Opera Presto's support is described in the following data table.

Method Description Support
querySelector()
  • This method must, when invoked, return the first matching Element
    node within the node's subtrees.
  • If there is no such node, the method must return null.
  • This method takes a selector string (selectors) as its argument.
Yes
querySelectorAll()
  • This method must, when invoked, return a NodeList containing all of the
    matching Element nodes within the node's subtrees, in document order.
  • If there are no such nodes, the method must return an empty NodeList.
  • This method takes a selector string (selectors) as its argument.
  • The NodeList object returned by the querySelectorAll() method
    must be static, not live.
Yes

Example

This is an example table written in HTML 4.01.

<table id="score">
  <thead>
    <tr>
      <th>Test
      <th>Result
  <tfoot>
    <tr>
      <th>Average
      <td>82%
  <tbody>
    <tr>
      <td>A
      <td>87%
    <tr>
      <td>B
      <td>78%
    <tr>
      <td>C
      <td>81%
</table>

In order to obtain the cells containing the results in the table, the following selector query may be used.

var cells = document.querySelectorAll("#score>tbody>tr>td:nth-of-type(2)");

This example returns a node list containing each of the cells in the second column. This could be useful, for example, to plot the values on a graph.

Selector API baseline tests

The Selector API baseline test case is composed of 1008 individual tests. Opera Presto registers a 100% pass rate when the test case is run. For your reference, the test case can be run here: W3C Baseline Tests: HTML with CSS Level 2.1 Selectors.

Documentation

Opera Help

Need help? Hit F1 anytime while using Opera to access our online help files, or go here.