Home>Support>Hide and Show Content jQuery wrong margin on streched layout

Hide and Show Content jQuery wrong margin on streched layout

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

Hello,

I’m using a jQuery to intially hide on row and only show the first row. The user can then switch and show a different row.

This is the script:

<script>
jQuery(document).ready(function() {
         jQuery('#divcontent2').hide();
         jQuery('#showall').click(function(){
               jQuery('.targetDiv').show();
               jQuery('.showSingle').removeClass("activetoogle");
               jQuery('#showall').addClass("activetoogle");
        });
        jQuery('.showSingle').click(function(){
              jQuery('.targetDiv').hide();
              jQuery('#showall').removeClass("activetoogle");
              jQuery('.showSingle').removeClass("activetoogle");
               jQuery('#divcontent'+jQuery(this).attr('target')).show();
            jQuery(this).addClass("activetoogle");
          
   });
});

The problem here is that the row (that is intially hidden) with layout “streched” and a background-color calculates the left margin wrong, when i show it by click on a button. So the backgroundcolor start with the content on the left and streches to the right.

Image here: Screenshot

Do you know a solution for this?

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 6 years, 9 months ago Alex S
    Hi, I Work Here

    Hi Simon,

    Do you have a public URL where we can take a look at what’s going on?
    The mentioned code shouldn’t cause any issues with our Full Width JavaScirpt as it applies regardless of visibility so I suspect something else may be interfering or there may be a general difference not highlighted that’s preventing our code from affecting your rows.

  2. 6 years, 9 months ago Simon Nowotny

    Hello Alex,

    thank you for your fast reply.

    https://www.campushelfer.de/de/siteorigin-test/
    and the password for this single page: test1

    The situation descriped above appers if you click on the right button “Ich bin Kunde”.

    Thank you!

    Simon

  3. 6 years, 9 months ago Alex S
    Hi, I Work Here

    Hi Simon,

    Thanks. Unfortunately, I’m not too sure why this is happening I would replicate the code we use to stretch rows to allow for the rows to be stretched.

  4. 6 years, 9 months ago Simon Nowotny

    Hello Alex,

    ok what a pitty. So by replicate you mean i should put the code in my function and executed “the streching” again manually?

  5. 6 years, 9 months ago Alex S
    Hi, I Work Here

    Hi Simon,

    Yes. You’ll need to manually stretch your rows to accomplish your desired setup. Sorry mate.

  6. 6 years, 9 months ago Simon Nowotny

    i’m not too familiar with jquery and stuff, so I use a little workaround now by applying

    margin-left:-300%!important;
    margin-right:-300%!important;
    padding-left:300%!important;
    padding-right:300%!important;

    to the two rows i would like to style. Works for now.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More