I have a div with id test
and through the foreach loop I am creating some inner divs inside the test div. So it becomes like this.
Use jQuery.
This code can be addapted to your needs:
$testDiv = $('div#test').first(); $('div', $testDiv).css("margin", '50px');