如果已单击,如何在文本框中显示标记的纬度/长度

   function getInfo() { 
    $.getJSON("get_info.php", function (data) { 
      for (var i = 0; i < data.length; i++) { 
        var location = new L.LatLng(data[i].lat, data[i].lng); 
        var marker = new L.Marker(location,{icon:Icon1}); 
           marker.bindPopup(
              data[i].name + "<br>" + 
              data[i].user_date + "<br>" + 
              data[i].user_time + "<br>" + 
              data[i].address + "<br>"
           ).addTo(map);
           marker.on('click', function(e) { // HERE YOU GO
                var ll = marker.getLatLng();
document.querySelector('#userLat').value = ll.lat;
document.querySelector('#userLng').value = ll.lng;
           });
         } 
    }); 
  } 

My code above works perfectly but I have one question. This will automatically generate marker in the map from database. I just wanna add a function that if the generated marker has been clicked it will show the markers lat/long in two diff textbox. how can i achieved this?

<text>Marker Latitude:<text>
<input id="userLat" type="text" name="userlat"  />
<text>Marker Longhitude:<text><br>
<input id="userLng" type="text" name="userlng"  /><br><br>

You are looking for Leaflet’s events:

marker.on('click', function(e) {
    alert('Event is printed out to console');
    console.log(e);
});

So your code is to be modified as:

function getInfo() { 
    $.getJSON("get_info.php", function (data) { 
      for (var i = 0; i < data.length; i++) { 
        var location = new L.LatLng(data[i].lat, data[i].lng); 
        var marker = new L.Marker(location,{icon:Icon1}); 
           marker.bindPopup(
              data[i].name + "<br>" + 
              data[i].user_date + "<br>" + 
              data[i].user_time + "<br>" + 
              data[i].address + "<br>"
           ).addTo(map);
           marker.on('click', function(e) { // HERE YOU GO
             alert('Event is printed out to console'); // THIS CODE IS TO BE CHANGED
             console.log(e);                           // TO UPDATE WHATEVER YOU WANT
           });
         } 
    }); 
  }