javascript - 调用单击事件时更改变量内部值的可能方法?
问题描述
我有一个名为“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)
解决方案
places.features[0].properties.name = "Trailer 2"
places.features[0].geometry.coordinates[0]=lg1
places.features[0].geometry.coordinates[1]=lt1
推荐阅读
- python - 有没有一种有效的方法来合并两个表?
- python - 代码“更快”地到达解决方案,这对大 O 运行时有何影响?
- c# - 多目标框架中的源代码
- java - Java 处理:使用鼠标围绕一个点旋转
- php - 如何在PHP中生成组合两个数组元素
- flutter - 在 Flutter 中调用 build 方法时如何获取子小部件的大小?
- node.js - 从 Node Js 和 Mongoose 中的应用程序收到的不完整响应
- mongodb - Spring Data 使用 DBRF 惰性属性更新 mongodb 文档
- c++ - 使用模板类抛出和捕获异常
- java - 在 Java 中 Ping 设备