I'm trying to get the data attribute of a div when clicked in Backbone events(View).
I'm able to achieve this if I click on the div listItem
but if I was to click on the child element span it will fail because $(e.target)
will be the span.
So how do I get the data attribute of the parent element, even if the child element is clicked?
<div class="listItem" data-showInfo="true">
<span class="arrow"></span>
</div>
events:{
"click .listItem": function(e) {
var $listItem= $(e.target);
console.log($listItem.data('showInfo'));
}
}