Announcement

Collapse
No announcement yet.

Add style to 'product list' with no content

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Add style to 'product list' with no content

    I use some script to hide div.product-details when empty:

    Click image for larger version

Name:	hide-product-details.jpg
Views:	102
Size:	36.4 KB
ID:	554697

    Code:
    <script>
    $("div.product-details").filter(function(){
    return $(this).text().trim() == ""
    }).remove();
    </script>
    Code:
    .product-details:empty {
    display: none!Important;
    width:0;
    margin:0;
    padding:0;
    border:0;
    }
    The problem is that div.product-list has a margin-bottom of 50px;

    Although 'empty' the script above does not work for the div.product-list

    How may I apply a style to the div.product-list when all it contains is empty, hidden divs?

    Thank you!

    https://www.graphicz.gb.net/sv2relea...-Earrings.html
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Looks like your JavaScript is located above the stuff you want it to work on. And is set to execute when it is encountered in the pages HTML. So it won't see the code it's meant to work on.

    Run it when the DOM is loaded.
    Code:
    <script>
    $(document).ready(function(){
    	$("div.product-details").filter(function(){
    		return !$.trim($this.text())
    		}).remove();
    	});
    </script>
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thank you very much Norman, I have also added 'visibility:hidden;' to the styles and that seems to do the trick.

      Code:
      .product-details:empty {
      display: none!Important;
      visibility:hidden;
      width:0;
      margin:0;
      padding:0;
      border:0;
      }
      There is an exclamation mark in your code absent in my original and it seemed to generate an error
      Code:
      return !$.trim($this.text())
      This in the JS Header Functions seems to work OK.

      Code:
      <actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22">
      <script>
      $(document).ready(function(){
      $("div.product-list").filter(function(){
      return $(this).text().trim() == ""
      }).remove();
      });
      </script>
      </actinic:block>
      Thank you again
      Jonathan Chappell
      Website Designer
      SellerDeck Website Designer
      Actinic to SellerDeck upgrades
      Graphicz Limited - www.graphicz.co.uk

      Comment

      Working...
      X