But $data is dynamically updated, so I was wondering if there is any
function that escapes the special characters on the fly.

Thanks,
Ramya

On Mar 24, 4:51 pm, James <james.gp....@gmail.com> wrote:
> This is basic programming...
>
> If your string is wrapped in single-quotes, and the content of your
> string contains single-quotes, you have to escape them:
> $data = 'Hey welcome to webpage, \'Enjoy\'';
>
> or you can use double-quotes to wrap the string:
> $data = "Hey welcome to webpage, 'Enjoy'";
>
> On Mar 24, 11:18 am, Ramyak <karri.ra...@gmail.com> wrote:
>
> > Hello,
>
> > Need help.
>
> > I want to dynamically update the contents of my div tag.
>
> > Therefore I used jquery and the code is as follows
>
> > $data= 'welcome to this page';
> > $("#element1").html($data);
>
> > This code works perfectly fine for simple data.
>
> > But for complex data say, $data = 'Hey welcome to webpage, 'Enjoy'';
>
> > $("#element1").html($data); doesnt work because the javascript fails.
>
> > Is there any jquery plugin that checks to see if the content in $data
> > is
> > valid.
>
> > Thank you,
> > Ramya
>
>

Reply via email to