2016-06-02 3 views
0

값 (자바 스크립트)이있는 경우 섹션 숨기기, 나는 내보기에 일부 변수를 전달 OR "> 0"나는 HIDE이 원하는Laravel 5.1 변수 내가 laravel 5.1 (전자 상거래)와 함께 일하고 있어요

예를 들어 10, 20 등 ...에 대한 :

<tr class="cart-subtotal" id="coupon"> 
<th>Coupon:</th> 
<td> 
<span class="amount">€{{ number_format($price_coupon, 2) }}</span> 
</td> 
</tr> 

$ price_coupon IF = 0 AND $ price_coupon> 0

내가 생각하는 경우 표시 그것은 바로 자바 스크립트에 대한 기능입니까? 어떻게 할 수 있니? 도와 줘서 고마워!

이 내보기의 모든 테이블 : 주문 detail.php

<table> 
     <tbody> 
      <tr class="cart-subtotal"> 
      <th>Subtotale:</th> 
       <td><span class="amount">€{{ number_format($total, 2) }}</span></td> 
       </tr> 

       <tr class="cart-subtotal" id="coupon"> 
       <th>Coupon:</th> 
       <td><span class="amount">€{{ number_format($price_coupon, 2) }}</span></td> 
       </tr> 

       <tr class="shipping"> 
       <th>shipping:</th> 
       <td>€<input type="text" id="price_ship" name="price_ship" class="price_ship" disabled /></td> 
       </tr> 

       <tr class="order-total"> 
       <th>Totale Ordine:</th> 
       <td><strong><span class="amount"> 
       €<input type="text" id="total_ship" name="total_ship" class="total_ship" disabled /> 

       </span></strong> </td> 
     </tr> 
</tbody> 
</table> 

내가이 질문을 수정 : 나는 또한 블레이드 템플릿을 사용하고 있습니다. 자바 스크립트

+1

'경우 (X == 0) {...}''--- 경우 (x> 0) {...}' . –

+0

이것이 마지막 단계 인 경우 Blade에서 직접 숨겨야합니다. – Pyton

+0

나는 어떻게 잎에 그것을 점칠 수 있냐? –

답변

1

(jQuery를)은 통화 및 소수점 값이 같은

if(parseInt($('.amount').text()) <= 0){ 
     $('.amount').closest('tr').css('display', 'none'); 
}else{ 
    $('.amount').closest('tr').css('display', ''); 
} 

또한

parseFloat() 

를 사용할 수 있습니다. 그러나 반올림 때문에 값이 0.4 이하인 경우에만 문제가됩니다.

이 이상한 물건은 무엇입니까? 파운드입니까? 우리는 단지 연못의 내 편에 $을 사용합니다. 나를 그들이 jQuery에 대해 이렇게하는 지 궁금하게한다. 흠 ...

나는 그의 가족을 방문하고있는 오래되었던 세계에서 돌아 간다라고하는 긴 이야기를 짧게 만들기 위해 실제로 영국 친구가있다. 100 파운드짜리 전화가있어. 나는 그에게 말했다. 와우, 그것은 무거운 롤이다.

1

안녕하세요 같이, 칼날이 해결 :

@if($price_coupon >0) 
    <tr class="cart-subtotal"> 
     <th>Sconto:</th> 
     <td><span class="amount">€{{ number_format($price_coupon, 2) }}</span></td> 
    </tr> 
@endif 
+1

당신은 블레이드 템플릿 시스템을 사용하고 있다고 언급 한 적이 없습니다. –

+0

예 죄송합니다. 질문을 수정했습니다. –

+0

내 편집을 수락 할 수 있으므로 내 downvote를 삭제할 수 있습니다. –