Reputation: 21
I have a problem with a jQuery script. I added a new DIV into a other DIV with the function append, but the CSS style doesn't pick the declared DIV class.
For example:
<style">
.example { background-color:#00000; }
</style>
$('#test).append('<div class="example"></div>');
I loaded the stylesheet with:
<link rel="stylesheet" type="text/css" href="./css/example.css">
Upvotes: 2
Views: 9518
Reputation: 14318
You can try the following :
$('#test').append($('<div></div>').attr('class', 'example'));
Or
$('#test').html('<div class="example"></div>');
Upvotes: 2