tags:

views:

53

answers:

3

What can I use in jquery instead of document.createTextNode(' ') js line.

I'm trying to do sth like this :

js : divButtons.appendChild(document.createTextNode(' '));

jquery : $("#divButtons").append(?????);

A: 

Am I lost or you just want to add text?

$("#divButtons").append(' ');
Reigel
Yes actually i used it but i'm not sure that it is true.. Because I don't know the details of createTextNode function.
penguru
+1  A: 

You can use append to append plain text:

$("#divButtons").append("Hello world")

However, if you only want to append a space, you have to use the   entity:

$("#divButtons").append(" ")
Niels van der Rest
+1  A: 

There is no equivalent in jQuery for createTextNode. You can always use the DOM method, or write a jQuery wrapper around it. The closest thing you may be able to find is when creating new elements, you can specify the text part separately.

$('<div>', {
    text: '<hello world>'
});
Anurag