我坚持使用html/JS,并不知道如何处理一些事件。 比如我有一个列表组:句柄bootstrap列表组点击
<div class="col-lg-3 col-md-3 col-sm-3 opciones">
<div class="list-group">
<a href="#" class="list-group-item active">
Tokyo
</a> // barfoobarfoo
<a href="#" class="list-group-item">London</a> // foo
<a href="#" class="list-group-item">Paris</a> // bar
<a href="#" class="list-group-item">Moscow</a> // foobar
<a href="#" class="list-group-item">NY</a> //foobarfoo
</div>
</div>
我想要做的是:
1)改变点击的活性元素。 2)调用单击元素时的JS函数。 UPD: 所以现在我知道点击事件可以用JQuery来处理。
我不明白的是如何确定哪个元素被点击。例如jQuery:
$('.list-group-item').on('click', function() {
$this = $(this);
$('.active').removeClass('active');
$this.toggleClass('active')
function simpleFunc(someargument) { //value of this argument depends on clicked item and can be (foo|bar|foobar) etc
document.write(someargument) // here whould be written some text (foo|bar|foobar) etc
})
没有教程或任何东西,除了这个HTML代码。 感谢
好的,你到目前为止使用JavaScript尝试过什么? –
我还没有尝试过任何东西。我只是不知道如何确定哪个元素被点击。我有启动Google地图的initMap函数。我想传递一些参数到这个func中,并在需要用特殊参数重新加载地图时调用它。 – alex111