Vanilla JavaScript - Wildcard (*) Selector

Raymond Tang Raymond Tang 0 4883 4.64 index 8/15/2022

Code description

In vanilla JavaScript, we can use wildcard (*) to match multiple elements (nodes) in the HTML DOM object. We can also match elements with attribute starting with, ending with or contains certain values.

For example, the following selectors will 

  • [name^="password"] will match all elements with name starting with password.
  • [name$="password"] will match all elements with name ending with password.
  • [name*="password"] will match all elements with name containing password.

Code snippet


javascript

Join the Discussion

View or add your thoughts below

Comments