In the following code, I am trying to get the last if statement to only minus the margin-top from the FIRST div.wigDiv parent. Everything is working, except that its applying the negative margin to ALL div.wigDiv parents. Any ideas?
$('.wigCont').each(function() {
//some other code here
if ($('div.wigDiv', this).hasClass('noMargin')) {
if (wigCount == 1) {
var width = $('div.wigDiv', this).width();
$('div.wigDiv', this).css({'margin-left':'-18px', 'width': width+36});
if ($('div.wigDiv', this).parent().first()) {
$('div.wigDiv', this).parent().css('margin-top','-20px');
}
}
}
}
Try this code: