I am trying to pull data from a data attribute of a link and decode the HTML in it, but it is not working.
Here is a JSFiddle of my code: http://jsfiddle.net/Kd25m/1/
HTML:
<a id="main" class="margin-right-5 no-underline" href="#" data-qid="0" data-name="Post\u0026#39;\u0026#39; \u0026#39;!@#$%^\u0026amp;*()_+{}|:\u0026quot;\u0026lt;\u0026gt;?,./;\u0026#39;[]\\212\u0026quot;\u0026quot;3\u0026quot;4567890-=\u0026#39;" data-caption="" data-description="Animals are generally considered to have evolved from a flagellated eukaryote.[39] \u0026#39;!@#$%^\u0026amp;*()_+{}|:\u0026quot;\u0026lt;\u0026gt;?,./;\u0026#39;[]\\21234567890-=\u0026#39;Their closest known living relatives are the ch...">
Alert Decoded HTML</a>
JS:
$('#main').click(function(e){
    e.preventDefault()
    //alert("AA");
    var name = $('#main').data('name');
    alert(name);
    var decoded = $("<div/>").html(name).text();
    alert(decoded);
});
Using this works if a string is put in the name var, but if I pull the value from the data attribute, it doesn't work anymore.
 
     
     
    