Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35452 > unrolled thread
| Started by | Luuk <luuk@invalid.lan> |
|---|---|
| First post | 2018-08-10 18:21 +0200 |
| Last post | 2018-08-18 17:01 +0200 |
| Articles | 5 on this page of 25 — 7 participants |
Back to article view | Back to comp.lang.javascript
addEventListener question Luuk <luuk@invalid.lan> - 2018-08-10 18:21 +0200
Re: addEventListener question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-11 00:04 +0200
Re: addEventListener question Luuk <luuk@invalid.lan> - 2018-08-11 14:28 +0200
Re: addEventListener question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-08-11 14:53 +0100
Re: addEventListener question "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-08-11 16:27 +0200
Re: addEventListener question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-08-12 17:49 +0200
Re: addEventListener question "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-08-12 18:05 +0200
Re: addEventListener question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-08-12 18:42 +0200
Re: addEventListener question "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-08-12 19:38 +0200
Re: addEventListener question Julio Di Egidio <julio@diegidio.name> - 2018-08-12 11:12 -0700
Re: addEventListener question James Kirk <noneya.invalid@gmail.com> - 2018-08-12 22:36 -0400
Re: addEventListener question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-09-06 08:17 +0200
Re: addEventListener question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-13 11:50 +0200
Re: addEventListener question Luuk <luuk@invalid.lan> - 2018-08-18 16:50 +0200
Re: addEventListener question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-11 16:58 +0200
Re: addEventListener question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-08-12 02:40 +0100
Re: addEventListener question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-08-12 09:07 +0200
Re: addEventListener question Luuk <luuk@invalid.lan> - 2018-08-11 19:17 +0200
Re: addEventListener question "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-08-11 16:30 +0200
Re: addEventListener question Luuk <luuk@invalid.lan> - 2018-08-11 19:12 +0200
Re: addEventListener question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-08-12 17:46 +0200
Re: addEventListener question "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-08-12 18:06 +0200
Re: addEventListener question "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-08-12 18:12 +0200
Re: addEventListener question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-08-12 18:33 +0200
Re: addEventListener question Luuk <luuk@invalid.lan> - 2018-08-18 17:01 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2018-08-12 17:46 +0200 |
| Message-ID | <c495979e-d1a2-57e6-a137-5d1061eeea20@PointedEars.de> |
| In reply to | #35457 |
Christoph M. Becker wrote:
> On 10.08.2018 at 18:21, Luuk wrote:
>> if (links[index].innerHTML== links[index].innerText) { abc++; }
>
> I'd prefer (assuming HTML):
>
> if (links[index].tagName === "DT") { abc++; }
const LINK = links[index];
if (LINK.tagName.toUpperCase() == "DT") { ++abc; }
or
Array.from(links).forEach((link) => {
/* … */
if (link.tagName.toUpperCase() == "DT") { ++abc; }
/* … */
});
Both assuming either ES 6 (2015) support on the clients or a transpiler like
Babel to make the code ES 5 (2009)-compliant.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2018-08-12 18:06 +0200 |
| Message-ID | <pkpltg$rrc$2@solani.org> |
| In reply to | #35463 |
On 12.08.2018 at 17:46, Thomas 'PointedEars' Lahn wrote:
> Christoph M. Becker wrote:
>
>> On 10.08.2018 at 18:21, Luuk wrote:
>>
>>> if (links[index].innerHTML== links[index].innerText) { abc++; }
>>
>> I'd prefer (assuming HTML):
>>
>> if (links[index].tagName === "DT") { abc++; }
>
> const LINK = links[index];
> if (LINK.tagName.toUpperCase() == "DT") { ++abc; }
Thanks! Indeed, I've missed the .toUpperCase().
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2018-08-12 18:12 +0200 |
| Message-ID | <pkpm99$sa0$1@solani.org> |
| In reply to | #35466 |
On 12.08.2018 at 18:06, Christoph M. Becker wrote:
> On 12.08.2018 at 17:46, Thomas 'PointedEars' Lahn wrote:
>
>> Christoph M. Becker wrote:
>>
>>> On 10.08.2018 at 18:21, Luuk wrote:
>>>
>>>> if (links[index].innerHTML== links[index].innerText) { abc++; }
>>>
>>> I'd prefer (assuming HTML):
>>>
>>> if (links[index].tagName === "DT") { abc++; }
>>
>> const LINK = links[index];
>> if (LINK.tagName.toUpperCase() == "DT") { ++abc; }
>
> Thanks! Indeed, I've missed the .toUpperCase().
Oh, actually I did not. .toUpperCase() would only be necessary for XHTML.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2018-08-12 18:33 +0200 |
| Message-ID | <b1b5af82-170f-6dd4-e3e8-3843636cc810@PointedEars.de> |
| In reply to | #35467 |
Christoph M. Becker wrote:
> Oh, actually I did not. .toUpperCase() would only be necessary for XHTML.
Are you willing to bet on the literal implementation of the DOM Specification?
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-08-18 17:01 +0200 |
| Message-ID | <5b7834cb$0$2959$e4fe514c@news.xs4all.nl> |
| In reply to | #35452 |
On 10-8-2018 18:21, Luuk wrote:
> Considering this piece of HTML:
> ....
> <dl id="csschart">
>
> <dt>001</dt>
> <dd class="p22"><span><b>22</b></span></dd>
> <dd class="sub p10" ><span><b>10</b></span></dd>
>
> <dt>002</dt>
> <dd class="p45"><span><b>45</b></span></dd>
> <dd class="sub p35"><span><b>36</b></span></dd>
>
> ....
After suggestions i would like to make a listener to listen to clicks on
a 'bar'.
A 'bar' is the combination of the 'dt' followed by 1 or more 'dd'-tags.
A solution could be to change the format of the HTML to:
<dl id="csschart">
<bar id='001'>
<dt>001</dt>
<dd class="p22"><span><b>22</b></span></dd>
<dd class="sub p10" ><span><b>10</b></span></dd>
</bar>
<bar id='002'>
<dt>002</dt>
<dd class="p45"><span><b>45</b></span></dd>
<dd class="sub p35"><span><b>36</b></span></dd>
</bar>
....
Then i can have a loop over all 'bar'-tags to add a listener to these
'bar'-tags.
something like (untested!):
var links=document.getElementsByTagnam('bar');
for (var j = 0; j < links.length; j++){
links.addEventListener('click',function(e) {
var xyz = 'X'; //special greetings to Thomas ;)
links.attributes[1].InnerText;
sendmsg('X' + j);
});
}
But 1 eventlistener shoud be so more simpler to have..
Can someone share some hints to have only 1 eventlistener, that returns
the 'bar' on wich was clicked considering the changed html posted above)
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.javascript
csiph-web