We would like to know how to get clicked anchor text.
<!DOCTYPE html>
<html>
<body>
<div id="bbtop"></div>
<div id="bbdefine"></div>
<ul class="dl-submenu">
<li><a>AAAAA</a></li>
<li><a>BBBBB</a></li>
<li><a>test</a></li>
<li><a>java2s.com</a></li>
</ul><!--from w w w . ja va2 s .co m-->
<script>
var bbdefine = document.getElementById('bbtop');
var elems = document.querySelectorAll('.dl-submenu li a');
for (var i=0; i<elems.length; ++i) {
elems[i].addEventListener('click', clickFunc);
}
function clickFunc(event) {
bbdefine.textContent = this.textContent+' Capacitor';
}
</script>
</body>
</html>
The code above is rendered as follows: