Advertisement
krot

JQuery удалить повторяющиеся элементы

Jul 4th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.72 KB | None | 0 0
  1. <th>
  2.  
  3. <select id="fcity" onchange="return change();">
  4. <option value="">Все города</option>
  5.  
  6.  
  7. </select>
  8.  
  9. </th>
  10.  
  11.  
  12. <td class="city">{$item.city}</td>
  13.  
  14.  
  15.  
  16. /*подготовить фильтр по городам*/
  17.         var supervise = {};
  18.         $(".city").each(function() {
  19.         var txt = $(this).text();
  20.         if (supervise[txt]){
  21.         //$(this).remove();
  22.         }else{
  23.         ($('#fcity').append('<option value="'+txt+'">'+txt+'</option>'))
  24.         supervise[txt] = true;
  25.         };
  26.         });
  27.      function change(){
  28.      op=$( "#fcity option:selected" ).val();
  29.      if(op=='')$(".city").parent().show();
  30.      else{
  31.      $(".city").each(function() {
  32.         if($(this).text()==op)$(this).parent().show();
  33.         else $(this).parent().hide();
  34.         });
  35.         }
  36.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement