首页 > 解决方案 > 调用单击事件时更改变量内部值的可能方法?

问题描述

我有一个名为“places”的变量。当单击事件侦听器时,有什么方法可以将我自己的变量值传递到位置。我的概念如下所示。如果这是不可能的,请原谅我。非常感谢。

var places = {
  'type': 'FeatureCollection',
  'features': [
    {
      'type': 'Feature',
      'properties': {
        'name': 'Trailer 1',  // change this value from Trailer 1 to Trailer 2
        'title': 'Trailer 1',
      },
      'geometry': {
        'type': 'Point',
        'coordinates': [lg13, lt13] // change this value to lg1 and lt1
      }
    }
  ]
};

************************* Event Listener ********************************

checkbox_1.addEventListener('click', function(e) {

  //change the values in places

}, false)





标签: javascript

解决方案


places.features[0].properties.name = "Trailer 2" places.features[0].geometry.coordinates[0]=lg1 places.features[0].geometry.coordinates[1]=lt1


推荐阅读