0

Please help i want to click this via javascript. How do you refer to this selected attribute?

enter image description here

Majkel36
  • 35
  • 1
  • 9
  • Are you asking how to write a CSS selector for that attribute? If so, `'[data-day="03.06.2020"]'`. If not, what are you asking? – jonrsharpe Jun 29 '20 at 13:23
  • That's how I want to click it using javascript how to write "Click" syntax for this element? document.getElementBy ...? – Majkel36 Jun 29 '20 at 13:24
  • Does this answer your question? [Select all elements with "data-" attribute without using jQuery](https://stackoverflow.com/questions/7084557/select-all-elements-with-data-attribute-without-using-jquery) – ABGR Jun 29 '20 at 14:03

3 Answers3

2

You can simply use document.querySelector():

document.querySelector('[data-day="03.06.2020"]').click()
palaѕн
  • 72,112
  • 17
  • 116
  • 136
1

This should do the trick:

const element = document.querySelectorAll('[data-day="03.06.2020"]');
console.log(element)
element.click();
Raffobaffo
  • 2,806
  • 9
  • 22
0

If you're looking for a pure JavaScript solution:

document.querySelector("[data-day='03.06.2020']").click();

Otherwise, if you have the JQuery library, use this:

$("[data-day='03.06.2020']").click();

I recommend using the 3.2.1 JQuery Library

Nanoo
  • 836
  • 8
  • 16