0

I'm using the Drupal Omega HTML5 starterkit theme and am trying to remove a block section and then cause the content region to expand to fill the extra space.

I found two things when I looked through the HTML output firstly in Omega it uses 'grid-($)' to determine the size of a div region.

Secondly the active layout type is listed as one of the body classes and changes depending on which is active at the time for example the one I'm trying to target is .responsive-layout-narrow.

I'm relatively new to JQuery but as a starting point I tried writing the following script

$(document).ready(function(){
    $("body").hasClass("responsive-layout-narrow"){
        $('#region-content').removeClass('grid-6').addClass('grid-8');
    }
}

So far I haven't been able to get this to work at all and any help would be appreciated.

thanks

1 Answer 1

1

You need an if statement there, since hasClass() returns a boolean:

if ($('body').hasClass('responsive-layout-narrow')) {
    $('#region-content').removeClass('grid-6').addClass('grid-8');
}

You can also use is() which is shorter:

if ($('body').is('.responsive-layout-narrow')) { // Notice the `.`
    $('#region-content').removeClass('grid-6').addClass('grid-8');
}

Also, be careful with mixing single and double quotes, it's a dangerous habit.

1
  • Thanks elclanrs I tried your updates and clean the code up but haven't had any luck yet. I think there might be a process somewhere in there blocking it which is a bit annoying Apr 15, 2012 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.