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 executed, right?
$line2 = i;'$line2 = i;does nothing as line2 it is overwritten in next line.addClassinstead. Something like this:$('<div/>').addClass('tagless').addClass(i).appendTo($('.quiztags'));