javascript - Bootstrap list-items activating on embedded span -
sorry title, found no better way describe it.
i have list-group , want buttons show specific color when active. somehow, embedded spans capture click , seem not count part of a
.
how can fix this? want button change color, no matter click (on span or anywhere else)
the code here: https://jsfiddle.net/zj6uwmvu/
thanks
here revised code click handler. if event target not link, means child badge clicked. if case, find closest link (the parent) , assign target.
$('.location').find('.location-picker-list .list-group-item').on('click', function(e) { var target = $(event.target); if (!target.is('a')) { target = target.parent('a') } e.preventdefault() target.closest('.list-group').children(".active").removeclass('active') target.addclass('active') })
Comments
Post a Comment