Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: addEventListener question Date: Sat, 11 Aug 2018 16:30:42 +0200 Organization: solani.org Lines: 35 Message-ID: References: <5b6dbba7$0$2957$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1533997840 29709 127.0.0.43 (11 Aug 2018 14:30:40 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 11 Aug 2018 14:30:40 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 X-User-ID: eJwFwYEBwCAIA7CXRGgL5zjQ/09YAqexFQQDD283pxLBWyPBmqGDyTpapyJ9W+t+Hhwst/4BCxYQVQ== Content-Language: de-DE Cancel-Lock: sha1:4PkYkS70YkNUwcPdxnVIvmrcl14= In-Reply-To: <5b6dbba7$0$2957$e4fe514c@news.xs4all.nl> Xref: csiph.com comp.lang.javascript:35457 On 10.08.2018 at 18:21, Luuk wrote: > Considering this piece of HTML: > .... >
> >
001
>
22
>
10
> >
002
>
45
>
36
> > .... > > > and this piece of javascript: > var links = document.getElementById('csschart').children; > var index; > var abc = -1;; > for (index = 0; index < links.length; ++index) { > if (links[index].innerHTML== links[index].innerText) { abc++; } I'd prefer (assuming HTML): if (links[index].tagName === "DT") { abc++; } > links[index].addEventListener('click',function(e) { > alert(abc); > }); > } -- Christoph M. Becker