-1

I would like to test if a page has the following div.

<div class="evs-embedded-card" data-id="10">some text</div>

How can I test to see if there is a div present that has both class="evs-embedded-card" and data-id="10"?

Franco
  • 2,846
  • 7
  • 35
  • 54

1 Answers1

1

You can use Document.querySelector() by specifying the class and attribute selector for the custom attribute without any space in between them.

var el = document.querySelector('.evs-embedded-card[data-id="10"]');
console.log(el);
<div class="evs-embedded-card" data-id="10">some text</div>
Mamun
  • 66,969
  • 9
  • 47
  • 59