0

I saw a sample which looked like this:

document.querySelector('#webchat > *').focus();

I know what it does (sets the focus into the sendbox of the webchat), but I dont understand what the " * " stands for. I know that #webchat is the "parent".

I implement the whole webchat with an external javascript, so I didn't code anything of the DOM. The sendbox's id is "webchat-sendbox-input" so nothing with a " * ".

Thats how the DOM looks like: enter image description here

BeschtPlaier
  • 133
  • 13

1 Answers1

2

See the specification:

The universal selector, written as a CSS qualified name [CSS3NAMESPACE] with an asterisk (* U+002A) as the local name, represents the qualified name of any element type. It represents any single element in the document tree in any namespace (including those without a namespace) if no default namespace has been specified for selectors. If a default namespace has been specified, see Universal selector and Namespaces below.

or MDN:

The CSS universal selector (*) matches elements of any type.

/* Selects all elements */
* {
  color: green;
}

or even W3Schools (which manages to correctly cover the basics for documents without namespaces):

Select all elements, and set their background color to yellow:

* {
    background-color: yellow;
}
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335