Well this is the problem, i have a "pre" tag with encoded html using htmlentities() from php that shows correctly on website.

But then i want to redecode it to put it in a "textarea" to work with in real time. (like stackoverflow does for example). And then this text modified is encoded (again and again) in the "pre" tag with the new info.

I tried this but it seems that it doesnt work, because the textarea is allways empty. This is the code:

i dont really understand how this code works, i know is wrong because jquery is far away from my mind, i saw others similar questions related to this using $('<div/>') before encoding but I dont think that was the problem. (i repeat that i am blind on this)

(sorry if i do too many mistakes, im not english writer as you can guess, and im not using translators)

EDITED

Well first part works now, Textarea is filled with the content of the PRE and is decoded (with <>and that kind of things) for real work.

Incidentally, $(src) gives you a detached DOM with the src, justs as $('<div/>') gives you a DOM containing one div. You seem to want the user to edit, not jQuey so you already have everything you need in src and don't need to create a DOM. You would only want to DOM if you wanted to insert elements from jQuery.

i modified a part of your code and it works, but i can give it back to the "pre" tag after the changes. var t0=$("textarea#textareaName0"), x0=$('pre#xmpName0'); t0.val(x0.text()); //dec t0.keyup(function(){ x0.innerHTML=t0.val(); //enc }); Take a look on the EDIT part.
–
Ignacio BustosAug 15 '13 at 0:20