Add text into a <span>

Add text into a <span>

Hi guys,

I have this script who will set a text to an existing or newly created <span>. When I executed the script, I can see ths <span> element to the source but the text never appear.
Here is the last version of this script (the alert box is displayed but the "_message" is never dispalyed to the page):
  1. var _message = response[inputId];
  2.    var $field = $(jqn('#'+inputId)); 
  3.    var $span  = $(jqn('#'+inputId+'.errors'));
  4.    /* If the span isn't already in this page and if we have a 
  5.     * message to display, we create the span. 
  6.     * If we have already a span in the page we empty it. */
  7.    if ( $span.length==0 && _message.length>0 ) {
  8.    $span = $('<span id="'+inputId+'.errors" '+ 
  9. 'class="message error"></span>')
  10. .css('float','right');
  11. $field.after($span);
  12.    } else {
  13.    $span.empty();
  14.    }

  15.    /* If we have a message we set the message and display it 
  16.     * else we hide the element that was created or cleared 
  17.     * previously. */
  18.    if ( _message.length>0 ) {
  19.     alert("Display "+_message+" in "+$span+" ("+$span.length+")");
  20.     //$span.html(_message);
  21.      //$span.text(_message);
  22.     $span.append(document.createTextNode("Hello"));
  23.     //$span.show();
  24.    } else {
  25. $span.hide();
  26.    }