Do you know that you have a discrepancy between your custom date-ref attribute in the text and "data-ref" in your jQuery?
Also, it might be easier for you to work with the jQuery object:
$(this).attr('data-ref');
JS Fiddle demo .
The problem is that you are not using a jQuery object:
this.attr('data-ref');
Unable to work
On the other hand, to retrieve the data-* attributes using the DOM, you have the following options:
this.getAttribute('data-ref');
Or:
this.dataset.ref;
Or:
this.dataset['ref'];
David thomas
source share