0

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

enter image description here

3
  • 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? Commented Jun 29, 2020 at 13:23
  • That's how I want to click it using javascript how to write "Click" syntax for this element? document.getElementBy ...? Commented Jun 29, 2020 at 13:24
  • Does this answer your question? Select all elements with "data-" attribute without using jQuery Commented Jun 29, 2020 at 14:03

3 Answers 3

2

You can simply use document.querySelector():

document.querySelector('[data-day="03.06.2020"]').click()
Sign up to request clarification or add additional context in comments.

Comments

1

This should do the trick:

const element = document.querySelectorAll('[data-day="03.06.2020"]');
console.log(element)
element.click();

Comments

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

2 Comments

Well, the problem is that I don't have a jquery library ... How do you write it in plain js?
@Majkel36 I updated my answer for a pure JavaScript solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.