Store your key in an attribute of the anchor tag
var text = '<a href="#"><h2>' + value + '</h2>' + '<a href="#" key="'+key+'" class="del">Delete</a></a>';
$('<li />', {
html: text
}).appendTo('ul.medList');
and in click event refer that attribute
$('ul').on('click', '.del', function (el) {
$(this).closest('li').remove();
var key = $(this).attr('key');
localStorage.removeItem(key); //Where problem relies
$('ul.medList').listview('refresh');
});
hope this solves your problem.