user3284463 user3284463 - 1 year ago 117
Javascript Question

addClass() not adding class

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>";
var close_button = '<span class="float-notification-close" style="float:right;cursor:pointer;">X</span>';
var content = $(wrapper).append(message + close_button);
//give wrapper a error class

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

Answer Source

U need to append it to body

var wrapper='<div class="float-notification"></div>';

It works!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download