You can give it a callback function that will have the this
scoped.
$('div').html(function(){
return $(this).data('test');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div data-test="test"></div>
<div data-test="secondary test"></div>
Or, seriously, just use a variable (if there is only one).
var $div = $('#element');
$div.html($div.data('test'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="element" data-test="test"></div>
3
solved this in chained jquery functions