L
L
Levorukij52018-02-02 00:40:55
JavaScript
Levorukij5, 2018-02-02 00:40:55

Why isn't a value assigned to the data-autorNAME attribute?

I'm trying to adapt this gallery for myself vodkabears.github.io/galereya I use
it on the page: https://pl-galerie.ru/galerie/
I want to add a new attribute to the picture: data-autorNAME. The value is assigned using PHP. When viewing the source code of the page, you can see that the attribute value is not empty.
The checks showed that in the code section and in the section in autorNAME an empty string is assigned. What can be wrong? The previous data-detail and data-autorURL attributes are handled correctly
autorNAME:a.autorNAME||""
autorNAME:b.getAttribute("autorNAME")||""

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-02-02
@Levorukij5

Firstly, you need to use lower case
Secondly, you need to get it from the dataset

<div id="b" data-author-name="ivan"></div>

var name = b.dataset.authorName;
alert(name);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question