2017-07-05 8 views
-1

私は2つの要素を表示/非表示に切り替えます。 私はトグルショーのブーンリンクを含むブロックを表示します。 ユーザーがブトンリンクをクリックしたときにトグルの例外を設定する必要があります。Jquery .not()は動作しません

私の機能が.notで機能しない場合は、助けてください。

// On cache le block d'ajout au panier et l'image dans le block texte 
    jQuery('.panier_block').hide(); 
    jQuery('.img_toggle').hide(); 

// les cachés s'affichent et les affichés se cachent avec toggle. 
    jQuery('.item').not('.btn-cart').click(function() { 
     jQuery(this).find('.panier_block').toggle(275); 
     jQuery(this).find('.product-image').toggle(275); 
     jQuery(this).find('.product-image-subtext').toggle(275); 
     jQuery(this).find('.product_info_sub_block_text').toggle(275); 

    }) 

マイHTML:

<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>"> 
     <!-- <a href="#" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" id="product-switch-<?php echo $z; ?>"> --> 
     <div class="product-image" id="product-switch-<?php echo $z; ?>"> 
      <?php $_imgSize = 398; ?> 
      <img id="product-collection-image-<?php echo $_product->getId(); ?>" 
       src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>" 
       alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> 
     </div> 
     <!-- </a> --> 

<!-- Panier--> 
    <div class="product_info_block panier_block"> 
    <div class="product_info_sub_block"> 

     <div class="product-info"> 
      <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2> 
      <?php 
      // Provides extra blocks on which to hang some features for products in the list 
      // Features providing UI elements targeting this block will display directly below the product name 
      if ($this->getChild('name.after')) { 
       $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); 
       foreach ($_nameAfterChildren as $_nameAfterChildName) { 
        $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); 
        $_nameAfterChild->setProduct($_product); 
        echo $_nameAfterChild->toHtml(); 
       } 
      } 
      ?> 
      <!-- Affiche le poids--> 
      <div class="block_weight_cat"> 

      <span class="weight_cat"> 
      <?php $_product = Mage::getModel('catalog/product')->load($_product->getId()); 
       $_weight = $this->htmlEscape($_product->getWeight()); 
       if ($_weight < 1) 
        $_weightstr = number_format($_weight*1000) . " mll"; 
       else 
        $_weightstr = number_format($_weight) . " cl"; 
       echo $_weightstr; 
       ?> 
      </span> 
     </div> 

      <?php echo $this->getPriceHtml($_product, true) ?> 
      <?php if($_product->getRatingSummary()): ?> 
      <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?> 
      <?php endif; ?> 


      <div class="actions"> 
       <?php if(!$_product->canConfigure() && $_product->isSaleable()): ?> 
        <button type="button" title="<?php echo $this->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button> 

       <?php elseif($_product->getStockItem() && $_product->getStockItem()->getIsInStock()): ?> 
        <a title="<?php echo $this->quoteEscape($this->__('View Details')) ?>" class="button" href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a> 
       <?php else: ?> 
        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p> 
       <?php endif; ?> 
       <ul class="add-to-links"> 
        <?php if ($this->helper('wishlist')->isAllow()) : ?> 
         <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li> 
        <?php endif; ?> 
        <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?> 
         <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li> 
        <?php endif; ?> 
       </ul> 
      </div> 
      <a class="discover"href="<?php echo $_product->getProductUrl() ?>" title="">En savoir plus</a> <span class="iconm-arrow_2"> </span> 

     </div> 
     </div> <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>"> 
    <!-- <a href="#" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" id="product-switch-<?php echo $z; ?>"> --> 
    <div class="product-image" id="product-switch-<?php echo $z; ?>"> 
    <?php $_imgSize = 398; ?> 
    <img id="product-collection-image-<?php echo $_product->getId(); ?>" 
     src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>" 
     alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> 
    </div> 
    <!-- </a> --> 

    <!-- Panier--> 
    <div class="product_info_block panier_block"> 
    <div class="product_info_sub_block"> 

     <div class="product-info"> 
     <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2> 
     <?php 
// Provides extra blocks on which to hang some features for products in the list 
// Features providing UI elements targeting this block will display directly below the product name 
if ($this->getChild('name.after')) { 
$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); 
foreach ($_nameAfterChildren as $_nameAfterChildName) { 
$_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); 
$_nameAfterChild->setProduct($_product); 
echo $_nameAfterChild->toHtml(); 
} 
} 
?> 
     <!-- Affiche le poids--> 
     <div class="block_weight_cat"> 

      <span class="weight_cat"> 
      <?php $_product = Mage::getModel('catalog/product')->load($_product->getId()); 
$_weight = $this->htmlEscape($_product->getWeight()); 
if ($_weight < 1) 
$_weightstr = number_format($_weight*1000) . " mll"; 
else 
$_weightstr = number_format($_weight) . " cl"; 
echo $_weightstr; 
?> 
      </span> 
     </div> 

     <?php echo $this->getPriceHtml($_product, true) ?> 
     <?php if($_product->getRatingSummary()): ?> 
     <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?> 
     <?php endif; ?> 


     <div class="actions"> 
      <?php if(!$_product->canConfigure() && $_product->isSaleable()): ?> 
      <button type="button" title="<?php echo $this->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button> 

      <?php elseif($_product->getStockItem() && $_product->getStockItem()->getIsInStock()): ?> 
      <a title="<?php echo $this->quoteEscape($this->__('View Details')) ?>" class="button" href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a> 
      <?php else: ?> 
      <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p> 
      <?php endif; ?> 
      <ul class="add-to-links"> 
      <?php if ($this->helper('wishlist')->isAllow()) : ?> 
      <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li> 
      <?php endif; ?> 
      <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?> 
      <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li> 
      <?php endif; ?> 
      </ul> 
     </div> 
     <a class="discover"href="<?php echo $_product->getProductUrl() ?>" title="">En savoir plus</a> <span class="iconm-arrow_2"> </span> 

     </div> 
    </div> 
    </div> 


    <!-- block de texte--> 
    <div class="product_info_block bg_cat"> 

    <div class="product-image-subtext img_toggle" id="product-switch-<?php echo $z; ?>" > 
     <?php $_imgSize = 398; ?> 
     <img id="product-collection-image-<?php echo $_product->getId(); ?>" 
      src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>" 
      alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> 
    </div> 

    <div class="product_info_sub_block product_info_sub_block_text"> 

     <div class="product-info"> 
     <h2 class="product-name product-name-cat"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2> 
     <?php 
// Provides extra blocks on which to hang some features for products in the list 
// Features providing UI elements targeting this block will display directly below the product name 
if ($this->getChild('name.after')) { 
$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); 
foreach ($_nameAfterChildren as $_nameAfterChildName) { 
$_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); 
$_nameAfterChild->setProduct($_product); 
echo $_nameAfterChild->toHtml(); 
} 
} 
?> 
     <?php if($_product->getRatingSummary()): ?> 
     <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?> 
     <?php endif; ?> 
     <div class="text_describe_cat"> 
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua 
      . Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit 
      in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> 
     </div> 

     </div> 
    </div> 
    </div> 


</li> 
     </div> 


     <!-- block de texte--> 
     <div class="product_info_block bg_cat"> 

     <div class="product-image-subtext img_toggle" id="product-switch-<?php echo $z; ?>" > 
      <?php $_imgSize = 398; ?> 
      <img id="product-collection-image-<?php echo $_product->getId(); ?>" 
       src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>" 
       alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> 
     </div> 

     <div class="product_info_sub_block product_info_sub_block_text"> 

      <div class="product-info"> 
       <h2 class="product-name product-name-cat"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2> 
       <?php 
       // Provides extra blocks on which to hang some features for products in the list 
       // Features providing UI elements targeting this block will display directly below the product name 
       if ($this->getChild('name.after')) { 
        $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); 
        foreach ($_nameAfterChildren as $_nameAfterChildName) { 
         $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); 
         $_nameAfterChild->setProduct($_product); 
         echo $_nameAfterChild->toHtml(); 
        } 
       } 
       ?> 
       <?php if($_product->getRatingSummary()): ?> 
       <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?> 
       <?php endif; ?> 
       <div class="text_describe_cat"> 
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua 
     . Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit 
     in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> 
       </div> 

      </div> 
      </div> 
      </div> 


    </li> 
+2

関連するHTMLを投稿してください。 –

+0

あなたはしたいですが、私は非常に長いです – kwiz

+1

**関連** HTMLをあなたの質問に投稿してください。投稿したコードには、 'item'クラスを持つ要素が1つだけあり、' .btn-cart'クラスを持つ他の要素が1つあります。 jQueryの「not」が何をしているか知っていますか? – PeterMader

答えて

1

.not()方法がコレクションからいくつかの要素を "フィルタリング" するために使用されます。それが動作していないように見える理由です

jQuery('.item')によって集められたコレクションは、クラスbtn-cartを有する任意の要素を持っていない...

+0

ハムノイズは、 btn-cart – kwiz

+0

「含む」は同じクラスではありません。 –

関連する問題