title: Leaflet: Hide/Show Markers that are being inserted dynamically into the map
body: <p>i'm inserting the map points like this:</p>
  
  <pre><code>function getPoints() {
    $.getJSON("get_users.php", function (data) {
      for (var i = 0; i &lt; data.length; i++) {
        var location = new L.LatLng(data[i].lat, data[i].lng);
        var name = data[i].name;
        var website = data[i].website;
        var teste = "teste" + website;
  
        var marker = new L.Marker(location, {
          icon: tree1
        });
        marker.bindPopup("&lt;a onclick='info()' style='font-size:18px; font-style: italic; font-family:courier; cursor: pointer;'&gt;" + name + "&lt;/a&gt;&lt;p&gt;" + city + "&lt;/p&gt;&lt;p id='inf' style='display:none;'&gt;" + website + "&lt;/p&gt;&lt;p style='font-size:10px;'&gt;" + location + "&lt;/p&gt;", {maxWidth: '400'});
        users.addLayer(marker);
      }
    }).complete(function() {
      if (firstLoad == true) {
        map.fitBounds(users.getBounds());
        firstLoad = false;
      };
    });
  }
  </code></pre>
  
  <p>And i wanted the users to be able to only see the markers, for example with the class "foo", using  javascript to hide the points that don't have that class.</p>
  
  <p>My problem is that i have not been able to assign a class to the marker.. i have tried:</p>
  
  <p>Using JQuery: <code>$(marker._icon).addClass(foo)</code> , <code>$(marker).addClass('foo')</code></p>
  
  <p>DomUtil: <code>DomUtil.addClass(marker, 'foo')</code> , <code>marker = L.DomUtil.addClass(marker, 'foo')</code></p>
  
  <p>Am i doing something wrong declaring the class? please correct me!</p>