Skip to main content
2 of 2
deleted 25 characters in body
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Dynamically Change Leaflet PopUp Background

Is there a way to set the background image of a leaflet pop up dynamically?

I have multiple markers with popups, which all need a different background image. The filepaths for the images are being pulled from a database.

I have tried using jQuery to change the background property of the ".custom-popup .leaflet-popup-content-wrapper" classes, but the change does not occur. When I type $(".leaflet-popup-content-wrapper") into the console, it returns an empty array which tells me that the current page cannot even see this class.

How can I dynamically apply a background image to each of the popups?