[jQuery] Dynamic update div tag; javascript fails for complex data

[jQuery] Dynamic update div tag; javascript fails for complex data


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