N'arrive pas à acceder à l'attribut data-
Bonjour à tous,
Je travaille sur un projet et je suis un peu embêter car je n'arrive pas à accéder à l'attribut data-category pour récuperer une liste de catégorie,
Code:
1 2 3 4 5 6 7
|
{% for tool in abcIngTools %}
<div class="col-sm-4 col-tool {% if user is defined and not user is empty %}
{{ tool in user.favoriteTools ? 'favorite-tool' : 'no-favorite-tool' }}{% endif %}"
data-tool="{{ tool.slug }}" data-category="{{ tool.category.nameCategory }}"
</div>
{% endfor %} |
Code:
1 2 3 4 5 6 7
|
for(let tool of $('.col-tool')) {
console.log(tool.data('category));
abcingTools.push(tool);
console.log(abcingTools);
} |
La console me retourne q
Code:
jquery.min.js:2 Uncaught TypeError: tool.data is not a function
Auriez-vous une solution ? svp