1

I am trying to get the list of all divs where class name contains bp-table-cell as a substring.

This returns divs that have class name exactly bp-table-cell

document.getElementsByClassName('bp-table-cell')

I found this which solves using jquery and need to solve without using jquery

$("div:regex(class, .*bp-table-cell.*)")
Suresh Pokharel
  • 412
  • 1
  • 8
  • 21
  • Please see the linked duplicate for the answer, essentially though the version of the answer in the linked duplicate for your specific case will be: `document.querySelectorAll('*[class*="bp-table-cell"]')`. In fact, jQuery inspired `document.querySelector` and as a result there are many overlapping features with regards to selectors. – Travis J Nov 07 '17 at 04:39
  • @TravisJ Thanks for this. I still need next thing to know, Is it possible to make the above regex to give different two substrings? For example, The div whose class name must contain both `bp-table-cell` and `bp-table-cell-col-0` but they don't come together. – Suresh Pokharel Nov 07 '17 at 07:00
  • `document.querySelectorAll('.bp-table-cell-col-0[class*="bp-table-cell"]')` – Travis J Nov 07 '17 at 07:41

0 Answers0