Replace all quotes inside your text variables with their correspondent
HTML entities, then you should face no issues:

titleFull = titleFull.replace("'","‘").replace('"',""");

I agree with Liam, it's best to use single quotes for the strings
passed so you can use double quotes inside them. In XHTML all atribute
values should use double quotes.

- ricardo

On Feb 4, 12:44 pm, dirk w <dirkwendl...@googlemail.com> wrote:
> hello jquery community,
> i am getting some strings from a page i don't have influence on. i
> just append those to elements (thanks to jquery this works like a
> charm!):
>
> $("#searchResultList").append("<li class='searchResultEntry'id='" +
> videoId + "' title='" + titleFull + " (" + minutes + ":" + seconds +
> ")'><img src='" + thumbnailUrl + "'        class='thumbnail' alt='" +
> titleFull + " (" + minutes + ":" + seconds + ")'/></li>");
>
> my problem is:
> sometimes the variable "title" contains a ' in the string, like
> "doesn't that look funny..." in this case my output get's completely
> messed up.
> is there a more reliable way to use ' and  " ? any ideas how i could
> prevent ' to crack this up?
>
> thanks in advance
> dirk

Reply via email to