2012-04-24 12 views

답변

0

당신이 당신의 if 문을 변경해야합니다

if (check && check.indexOf(letter) > 0) { 
    $(this).parent().show(); 
} 

귀하의 상태가 선택된 값이 좋아되지 않은 경우에만 사실이었다 (== 대신>의). 또한 each() 루프 내에서 부모를 가져 오려면 항상 현재 객체를 참조해야합니다.

웹 사이트에서 $(document).ready() 이벤트 코드를 래핑해야합니다. 이 시도 : 바이올린에서 작동하는 듯하지만,

jQuery(document).ready(function() { 
    jQuery('select.filterMe').change(function(e) { 
     var letter = jQuery(this).val(); 
     if (letter === 'ALL') { 
      jQuery('tr').show(); 
     } 
     else { 
      jQuery('tr').each(function(rowIdx,tr) { 
       jQuery(this).hide().find('td').each(function(idx, td) { 
        if(idx === 0 || idx === 1) { 
         var check = jQuery(this).text(); 
         if (check && check.indexOf(letter) > 0) { 
          jQuery(this).parent().show(); 
         } 
        } 
       });    

      }); 
     }    
    });​ 
});​ 
+0

전에서 내 웹 페이지를 통해 이동할 때 http://visitkoko.edventura.com/index.php?option=com_content&view=article&id=5&Itemid = 5, 작동하지 않습니다. 어떤 아이디어? – fuelishways

+0

@fuelishways, 내 대답을 편집했습니다. 희망이 도움이 될 것입니다 –

+0

기회가 당신은이 바이올린을 볼 수 있을까요? 드롭 다운을 기반으로하는 리를 보여주기 위해 필터링하려고합니다. [link] (http://jsfiddle.net/fuelishways/hu3A2/) – fuelishways