[英]Add class on click to a path with leaflet js
The function app
in your code only creates a function (and nothing more). 您代码中的function app
仅创建一个函数(仅此而已)。 This function is only created, but never fired. 该函数仅创建,但从未触发。 Another problem is that this function does nothing that relevant to the element that was clicked. 另一个问题是此功能与被单击的元素无关。
Here is the change you are looking for: 这是您要查找的更改:
function app(e) {
this.getElement().classList.add('active')
}
Here is a working codepen (based on your code): 这是一个有效的Codepen(根据您的代码):
http://codepen.io/anon/pen/pEmMRE http://codepen.io/anon/pen/pEmMRE
I added the
active
class to the CSS so you can actually see the change on the screen 我将active
类添加到CSS中,因此您实际上可以在屏幕上看到更改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.