A
A
Anastasia2018-02-21 14:34:17
JavaScript
Anastasia, 2018-02-21 14:34:17

How to find an element by an atypical attribute?

I want to grab a span element (to change it later) inside a div with "data-date" attribute equal to "2018-1-23".

<div data-year="2018" data-month="1" data-day="23" class="calendar-day" data-date="2018-1-23">
<span>23</span>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2018-02-21
@lastees

console.log(jQuery('div[data-date="2018-1-23"]'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question