jQuery append does not apply CSS styling
My jquery code is appending a piece of HTML in code properly, but the CSS styles are not applied after the HTML has been appended.
What is the right way to do it?
This is how I am doing:
if(listone[i] != "")
{
var l1pos = listone[i];
$('ul.ulstep1 li').eq(i).addClass('selected');
$line1= '<div class="tagless ';
$line2 = i;
$line2='><div class="tagleft"></div><span>';
$line2 += listone[i];
$line3 = '</span><div class="tagright"></div></div>';
$('.quiztags').append($line1+$line2+$line3);
$('.quiztags').append($('<div></div>').attr('class', 'tagless'));
}
This gives me the right HTML but no styling is applied. I am doing this operation inside a javascript onload function, so the CSS should have loaded when this is e开发者_Python百科xecuted, right?
Try it, maybe it works.
if(listone[i] != "")
{
$('ul.ulstep1 li').eq(i).addClass('selected');
var line1 = '<div class="tagless ';
var line2 = i;
line2 += '"><div class="tagleft"></div><span>';
line2 += listone[i];
var line3 = '</span><div class="tagright"></div></div>';
$('.quiztags').append(line1+line2+line3);
$('.quiztags').append($('<div></div>').attr('class', 'tagless'));
}
精彩评论