我堅持使用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