I am currently parsing a XML file and one field is an integer that determine the size of the object:
$(xml).find('Boxes').each(function(){
var top = $box.find('top').text();
}
then to display it with HTML:
var html = '<div class="box" style= top:'+ top +'px; </div>';
I want to add a constant number, 300, to top, I tried:
var html = '<div class="box" style="text-align:left; top:'+(parseInt(top)+300).text()+'px; </div>';
But this did not display correctly, is this the right way to do this?
>), that might be your problem right there.var topY, it is within the scope of that function. That variable can't be used outside of the function, so either a) make it global or b) put the html inside the function too.