Sample code:
DEMOCode:<!DOCTYPE html> <html lang="en"> <head> <title>Get elements number</title> </head> <body> <p class="">Hello, world!</p> <p class="5">Hello, world!</p> <p class="9">Hello, world!</p> <p class="">Hello, world!</p> <script> console.log(document.querySelectorAll("p[class]").length); </script> </body> </html>
What I get:4
What I expect:2
Bookmarks