I am trying to console.log the 'data-id' attribute however I keep getting 1 in my console when I click on a new '.dropdown-item'. This is a snippet of the HTML:
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
{% for date in joined_dates %}
<a class="dropdown-item" href="#" data-id="{{loop.index}}">{{date}}</a>
{% endfor %}
</div>
This is a snippet of the javascript:
d3.json('/data', function(error, closure_data) {
var btn = d3.selectAll('.dropdown-item')
btn.forEach(function(value, index) {
value = btn.attr('data-id')
btn.on('click', function() {
d3.select('#text').text('1')
console.log(value)
})
})
})