var DtControl = L.Control.extend({ options: { position: 'topleft' }, onAdd: function(map) { var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control'); container.title = 'Hide/Show DataTables'; container.innerHTML = ``; L.DomEvent.disableClickPropagation(container); /* Prevent click events propagation to map */ return container; } }); map.addControl(new DtControl()); map.on('click', unfocusLayer);