I was having difficulties storing text in the title attribute when it contained special characters. My workaround was to use escape/unescape. Is this the best way to resolve this? Why is it okay to include special characters in the alert function (i.e. Doesn’t work), but not in the title attribute? Thanks
[CODE]var t=’This works because it does not have special characters’;
$(‘body’).append(‘<br /><a id=”a1″ href=”#” title=”‘+t+'”>test</a>’);
alert($(‘#a1’).attr(‘title’));
var t=’This does not works because it “has” special characters”‘;
$(‘body’).append(‘<br /><a id=”a2″ href=”#” title=”‘+t+'”>test</a>’);
alert($(‘#a2’).attr(‘title’));
var t=escape(‘This works because the “special characters” are escaped’);
$(‘body’).append(‘<br /><a id=”a3″ href=”#” title=”‘+t+'”>test</a>’);
alert(“Doesn’t work: “+$(‘#a3’).attr(‘title’));
alert(“Does work: “+unescape($(‘#a3’).attr(‘title’)));