How would one get a custom attribute with Jquery
You're aware that you have a discrepancy between your custom attribute 'date-ref' in your text, and 'data-ref' in your jQuery?
Also, you might find it easier to work with the jQuery object:
$(this).attr('data-ref');
JS Fiddle demo.
The problem, indeed, seems to be that you weren't using a jQuery object:
this.attr('data-ref');
Can't work
On the other hand, to retrieve data-*
attributes using the DOM, you do have the options of:
this.getAttribute('data-ref');
Or:
this.dataset.ref;
Or:
this.dataset['ref'];
$("selector").attr("data-ref");
Should definitly work.
Maybe you can post your html code.