2014-02-18 3 views
0
.find('.woocommerce-tabs').not('.tabs').html(); 

위는 jQuery를의 일부가 클래스를 찾을 수 있지만, .woocommerce-tabs 요소의 자식입니다 .tabs를 제외하는 데 사용됩니다) (이 아니요 사용하여 콘텐츠의 일부를 제외합니다.jQuery를이

여전히 .tabs은 내가 원하는 바가 아닌 출력물에 나타납니다.

<div class="woocommerce-tabs"> 
    <ul class="tabs"> 

     <li class="description_tab active"> 
      <a href="#tab-description">Description</a> 
     </li> 


     <li class="additional_information_tab"> 
      <a href="#tab-additional_information">Additional Information</a> 
     </li> 

    </ul> 

    <div class="panel entry-content" id="tab-description" style="display: block;"> 

     <h2>Product Description</h2> 

     <ul> 
      <li>Robust</li> 
      <li>Continuous 360° turntable rotation</li> 
     </ul> 
    </div> 


    <div class="panel entry-content" id="tab-additional_information" style="display: none;"> 

     <h2>Additional Information</h2> 

     <table class="shop_attributes"> 
      <tbody> 
       <tr class=""> 
        <th>Tires (foam-filled)</th> 
        <td> 
         <p>16"</p> 
        </td> 
       </tr> 
       <tr class=""> 
        <th>Weight (kg)</th> 
        <td> 
         <p>6950</p> 
        </td> 
       </tr> 
      </tbody> 
     </table> 
    </div> 

</div> 
+1

당신은 아마 그것을 위해 HTML을 게시 할 수 : 다음

var clone = $'.woocommerce-tabs').clone(); clone.find('.tabs').remove(); var html = clone.html(); 

당신은 당신의 코드 내부 html를 복제 할 수 있습니까? – Joseph

+0

@Joseph html 예제가 추가되었습니다. – ngplayground

답변

1

코드는 tabs이없는 요소를 필터링 className은 지정을 제외하지 않습니다. d 요소를 html 출력에서 ​​가져옵니다. 요소 .clone()을 사용할 수 있고 자손을 제거한 다음 .html() 메서드를 호출 할 수 있습니다.

.find('.woocommerce-tabs').clone().find('.tabs').remove().end().html(); 

http://jsfiddle.net/aT7zX/

0

예를 들어, HTML 출력은 :has()

.find('.woocommerce-tabs').not(':has(.tabs)').html(); 

.not(':has(.tabs)')이 클래스 요소가 요소를 선택하지보십시오 tabs

0

한 가지 방법은 .woocommerce-tabs를 복제하고 복제 요소에서 .tabs을 제거하는 것입니다.

.find('.woocommerce-tabs').not('.tabs').html(html);