I\'m using jQuery\'s .data()
to work with custom HTML5 data attributes where the value of the attribute needs to be able to contain both single quotes and doubl
If they have to be HTML strings with "
and '
and whatnot, why not just make separate HTML elements for them: http://jsfiddle.net/N7XXu/.
E.g. the HTML:
a
She said "WTF" on last night's show.
in combination with the following JavaScript:
$('.example').each(function() {
var correspondingElem = $('.example-data[data-which="'
+ $(this).data('which')
+ '"]');
$(this).data('example', correspondingElem.html());
});
alert($('.example').data('example'));
Of course, hide the .example-data
elements.