Are you purposely trying to append the string '<td>' or are you trying to
append an invalid td element? If you're trying just trying to append strings
with special characters, use regular expressions to strip out special
characters:
var input = '<td> \'Jack\' & "Jill"';
input.replace(/&/g,'&');
input.replace(/</g,'<');
input.replace(/>/g,'>');
input.replace(/"/g,'"');
input.replace(/'/g,''');
Now input = '<td> 'Jack' & "Jill"', which
contains no invalid characters.
If you're trying to insert invalid elements (missing closing tags, etc), I'm
not sure what you would have to do, I think append tries to fix any invalid
DOM insertions...
- jake
On 2/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi, I want to append text to a node. I'm using this code
$(this).parents("div.sidebarToDo").find("td.sidebarText
").empty().append(val);
but if the variable "val" contains special characters, like "<td>", that
will mess up the rest of my tree. What is the best way to handle this?
Thanks, - Dave
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/