Question: I'm trying to add a class to a element but it doesn't seem to be adding the class.

This is what my code looks like:

```
var wrapper='<div class="float-notification"></div>';
var message="<span>" + message + "</span>";
      if(error==true){
        var close_button = '<span class="float-notification-close" style="float:right;cursor:pointer;">X</span>';
        var content = $(wrapper).append(message + close_button);
        $(this).append(content);
        //give wrapper a error class 
        $(wrapper).addClass('error');         
      }else{.....

```

I've also tried this with `$(wrapper).append("Foo Bar")` and it works as expected, So why won't `addClass()` work?

Answer: 
U need to append it to body

```
var wrapper='<div class="float-notification"></div>';
$(wrapper).addClass('error').appendTo('body');

```

It works!
`$(wrapper)` converts the string of HTML into a DOM node and wraps it in a jQuery object.

`.addClass('error')` then adds a class to that DOM node.

You then don't do anything with the return value and you don't use a method such as `appendTo` to put in to the document. So the jQuery object (and the DOM node inside it) is discarded.

(The original string of HTML is never modified).