Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31660 > unrolled thread

How to replace a class?

Started byjustaguy <lichunshen84@gmail.com>
First post2016-11-08 18:53 -0800
Last post2016-11-10 21:01 +0100
Articles 12 on this page of 32 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-08 18:53 -0800
    Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 07:45 -0800
      Re: How to replace a class? Ram Tobolski <ramtob@gmail.com> - 2016-11-10 10:08 -0800
        Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 11:58 -0800
          Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 13:06 -0800
            Re: How to replace a class? Ram Tobolski <ramtob@gmail.com> - 2016-11-10 13:37 -0800
              Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 14:09 -0800
                Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-11 00:01 +0100
            Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-10 22:51 +0100
              Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 14:09 -0800
          Re: How to replace a class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-10 23:20 +0100
            Re: How to replace a class? John Harris <niam@jghnorth.org.uk.invalid> - 2016-11-11 10:24 +0000
              Re: How to replace a class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-11 12:37 +0100
                Re: How to replace a class? John Harris <niam@jghnorth.org.uk.invalid> - 2016-11-12 17:09 +0000
            Re: How to replace a class? John Harris <niam@jghnorth.org.uk.invalid> - 2016-11-11 10:41 +0000
              Re: How to replace a class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-11 12:43 +0100
                Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-11 14:52 +0100
                  Re: How to replace a class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-11 15:11 +0100
                    Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-11 15:30 +0100
                      Re: How to replace a class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-11 16:41 +0100
                        Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-11 23:54 +0100
                Re: How to replace a class? John Harris <niam@jghnorth.org.uk.invalid> - 2016-11-12 18:42 +0000
              Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-11 14:46 +0100
                Re: How to replace a class? John Harris <niam@jghnorth.org.uk.invalid> - 2016-11-12 14:51 +0000
                  Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-12 20:13 +0100
                    Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-12 11:35 -0800
                    Re: How to replace a class? John Harris <niam@jghnorth.org.uk.invalid> - 2016-11-13 11:13 +0000
        Re: How to replace a class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-10 23:11 +0100
          Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 15:08 -0800
      Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-10 20:37 +0100
        Re: How to replace a class? justaguy <lichunshen84@gmail.com> - 2016-11-10 11:59 -0800
          Re: How to replace a class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-10 21:01 +0100

Page 2 of 2 — ← Prev page 1 [2]


#31706

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-11-11 23:54 +0100
Message-ID<XnsA6BDF32CD7063eejj99@194.109.6.166>
In reply to#31700
Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote on 11 Nov 2016 in 
comp.lang.javascript:

>> Many email-addresses are not email-boxes.
> 
> Utter nonsense.

I need only one example to contradict you,
that is the joy of logic:

A forwarding email-address is NOT an email-box.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31709

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-11-12 18:42 +0000
Message-ID<njoe2chbf28fjq9fsjg4acpkak4go7e8l5@4ax.com>
In reply to#31687
On Fri, 11 Nov 2016 12:43:33 +0100, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:

  <snip>
>IOW, exxjxw.hannivoort@inter.nl.net is not an e-mail address.
  <snip>

It is an e-mail address, in the same way that FFFFFFFF FFFFFFFF is a
computer's RAM address, even though it might not have been installed.

Presumably you meant address of a mailbox. You should be more careful
with your terminology.

And, of course, if a mailbox does not exist in this minute that is no
proof at all that it didn't exist when the article was constructed.

  John

[toc] | [prev] | [next] | [standalone]


#31688

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-11-11 14:46 +0100
Message-ID<XnsA6BD9658CD334eejj99@194.109.6.166>
In reply to#31684
John Harris <niam@jghnorth.org.uk.invalid> wrote on 11 Nov 2016 in 
comp.lang.javascript:

> As for Netiquette, the rules obviously depend on his nationality.

How would you know my nationality or nationalities?

You would not and do not!

What could one's nationality have to do with Usenet Netiquette?

Nothing!

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31707

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-11-12 14:51 +0000
Message-ID<dvae2c1qrcp1un6sevuff4bd56pus4qd1l@4ax.com>
In reply to#31688
On Fri, 11 Nov 2016 14:46:46 +0100, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:

>John Harris <niam@jghnorth.org.uk.invalid> wrote on 11 Nov 2016 in 
>comp.lang.javascript:
>
>> As for Netiquette, the rules obviously depend on his nationality.
>
>How would you know my nationality or nationalities?
>
>You would not and do not!
>
>What could one's nationality have to do with Usenet Netiquette?
>
>Nothing!

On the contrary, Evertjan. The guidelines for the German Usenet
hierarchy are different from the guidelines for the UK Usenet
hierarchy. That's why Netiquette depends, to some extent, on the
author's nationality. I don't need to know your nationality to be
absolutely certain that there are other people with a different
nationality. That's all I said, if you read it carefully.

  John

[toc] | [prev] | [next] | [standalone]


#31710

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-11-12 20:13 +0100
Message-ID<XnsA6BECDB7C4C5Aeejj99@194.109.6.166>
In reply to#31707
John Harris <niam@jghnorth.org.uk.invalid> wrote on 12 Nov 2016 in 
comp.lang.javascript:

> On Fri, 11 Nov 2016 14:46:46 +0100, "Evertjan."
> <exxjxw.hannivoort@inter.nl.net> wrote:
> 
>>John Harris <niam@jghnorth.org.uk.invalid> wrote on 11 Nov 2016 in 
>>comp.lang.javascript:
>>
>>> As for Netiquette, the rules obviously depend on his nationality.
>>
>>How would you know my nationality or nationalities?
>>
>>You would not and do not!
>>
>>What could one's nationality have to do with Usenet Netiquette?
>>
>>Nothing!
> 
> On the contrary, Evertjan. The guidelines for the German Usenet
> hierarchy are different from the guidelines for the UK Usenet
> hierarchy. That's why Netiquette depends, to some extent, on the
> author's nationality.

You are totally wrong here.

The different usenet hierarchies have nothing to do 
with the nationality or nationalities of a specific user.
And Netiquette addresses the conduct of those.

btw, Usenet does not have authors, only users. 
Perhaps that's why it is not called Authornet.

> I don't need to know your nationality to be
> absolutely certain that there are other people with a different
> nationality.

I don't see your point.

> That's all I said, if you read it carefully.

Read exactly what carefully? 
On Usenet referring to earlier postings should be quoted.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31711

Fromjustaguy <lichunshen84@gmail.com>
Date2016-11-12 11:35 -0800
Message-ID<3d0e7e15-d59c-4bee-8195-5d50225432c7@googlegroups.com>
In reply to#31710
On Saturday, November 12, 2016 at 2:14:06 PM UTC-5, Evertjan. wrote:
> John Harris .... wrote on 12 Nov 2016 in 
> comp.lang.javascript:
> 
> > On Fri, 11 Nov 2016 14:46:46 +0100, "Evertjan."
> > <exxjxw.hannivoort@inter.nl.net> wrote:
> > 
> >>John Harris <...> wrote on 11 Nov 2016 in 
> >>comp.lang.javascript:
> >>
> >>> As for Netiquette, the rules obviously depend on his nationality.
> >>
> >>How would you know my nationality or nationalities?
> >>
> >>You would not and do not!
> >>
> >>What could one's nationality have to do with Usenet Netiquette?
> >>
> >>Nothing!
> > 
> > On the contrary, Evertjan. The guidelines for the German Usenet
> > hierarchy are different from the guidelines for the UK Usenet
> > hierarchy. That's why Netiquette depends, to some extent, on the
> > author's nationality.
> 
> You are totally wrong here.
> 
> The different usenet hierarchies have nothing to do 
> with the nationality or nationalities of a specific user.
> And Netiquette addresses the conduct of those.
> 
> btw, Usenet does not have authors, only users. 
> Perhaps that's why it is not called Authornet.
> 
> > I don't need to know your nationality to be
> > absolutely certain that there are other people with a different
> > nationality.
> 
> I don't see your point.
> 
> > That's all I said, if you read it carefully.
> 
> Read exactly what carefully? 
> On Usenet referring to earlier postings should be quoted.
> 

Hi, all three of you probably belong to the top 5% of programmers. I greatly appreciate your expertise and advice and let me assume the fault of the recent arguments for the simple fact it stems from this thread which I started.  Could you guys look at the updates of the other thread about how to save an HTML page that has many dynamically generated elements via DOM?
Thanks.

[toc] | [prev] | [next] | [standalone]


#31712

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-11-13 11:13 +0000
Message-ID<nhig2ct337ipa2ta8662fb229gki4epmhh@4ax.com>
In reply to#31710
On Sat, 12 Nov 2016 20:13:22 +0100, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:

>John Harris <niam@jghnorth.org.uk.invalid> wrote on 12 Nov 2016 in 
>comp.lang.javascript:
>
>> On Fri, 11 Nov 2016 14:46:46 +0100, "Evertjan."
>> <exxjxw.hannivoort@inter.nl.net> wrote:
>> 
>>>John Harris <niam@jghnorth.org.uk.invalid> wrote on 11 Nov 2016 in 
>>>comp.lang.javascript:
>>>
>>>> As for Netiquette, the rules obviously depend on his nationality.
>>>
>>>How would you know my nationality or nationalities?
>>>
>>>You would not and do not!
>>>
>>>What could one's nationality have to do with Usenet Netiquette?
>>>
>>>Nothing!
>> 
>> On the contrary, Evertjan. The guidelines for the German Usenet
>> hierarchy are different from the guidelines for the UK Usenet
>> hierarchy. That's why Netiquette depends, to some extent, on the
>> author's nationality.
>
>You are totally wrong here.
>
>The different usenet hierarchies have nothing to do 
>with the nationality or nationalities of a specific user.
>And Netiquette addresses the conduct of those.

But the guidelines talk of Netiquette items - attributions for
instance. Germans don't have to take any notice of the German
guidelines, but some do. Britons don't have to take any notice of the
UK guidelines, but some do. Nationality can make a difference.


>btw, Usenet does not have authors, only users. 
>Perhaps that's why it is not called Authornet.

Each Usenet article does have an author, or are you claiming to be an
AI entity?


>> I don't need to know your nationality to be
>> absolutely certain that there are other people with a different
>> nationality.
>
>I don't see your point.

See above : your nationality can make a difference, and that is so
regardless of your actual nationality. Remark : you claimed that I
didn't know your nationality; I'm pointing out that it's irrelevant.


>> That's all I said, if you read it carefully.
>
>Read exactly what carefully? 
>On Usenet referring to earlier postings should be quoted.

It's already quoted at the beginning of the article. I'm not going to
quote it twice.

  John

[toc] | [prev] | [next] | [standalone]


#31673

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-11-10 23:11 +0100
Message-ID<20855761.ouqheUzb2q@PointedEars.de>
In reply to#31662
Ram Tobolski wrote:

>> Then, there would variable length of such elements, how do I replace all
>> the elements with class name of "Space" with another class?
> 
> Like this?
> 
> let elements = document.getElementsByClassName("Space");
> elements.forEach(element => element.className = newClass);

This cannot work because d.gEBCN() only returns a reference to an array-
*like* object which does not have a forEach() method by default.  You have 
to convert that object to an Array instance, or call 
Array.prototype.forEach() explicitly:

  [].forEach.call(elements, element => element.className = newClass);

Besides, the question was gibberish.  Your code does not replace the 
elements, it replaces the *class attribute value* of matching elements.

It remains to be seen whether that is really what the OP wants.  It is 
equally possible that they only want to exchange the class name in the 
attribute value:

  let oldClassName = "Space";
  [].forEach.call(
    document.getElementsByClassName(oldClassName),
    element => {
      element.classList.remove(oldClassName);
      element.classList.add(anotherClassName);
    });

      [We can reasonably assume that HTML user agents that provide an 
       ECMAScript 2015+ implementation for “let” and the arrow function
       syntax also support the DOM4 “classList” property.  The vice-versa
       assumption is not valid.]

Usually you would just add or remove a class name to/from the attribute 
value instead.  A stylesheet that requires renaming of a class name in
the attribute value for proper presentation is most certainly ill-designed.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#31677

Fromjustaguy <lichunshen84@gmail.com>
Date2016-11-10 15:08 -0800
Message-ID<af37f568-7a45-48c1-a3aa-909c0444f893@googlegroups.com>
In reply to#31673
On Thursday, November 10, 2016 at 5:11:55 PM UTC-5, Thomas 'PointedEars' Lahn wrote:
> Ram Tobolski wrote:
> 
> >> Then, there would variable length of such elements, how do I replace all
> >> the elements with class name of "Space" with another class?
> > 
> > Like this?
> > 
> > let elements = document.getElementsByClassName("Space");
> > elements.forEach(element => element.className = newClass);
> 
> This cannot work because d.gEBCN() only returns a reference to an array-
> *like* object which does not have a forEach() method by default.  You have 
> to convert that object to an Array instance, or call 
> Array.prototype.forEach() explicitly:
> 
>   [].forEach.call(elements, element => element.className = newClass);
> 
> Besides, the question was gibberish.  Your code does not replace the 
> elements, it replaces the *class attribute value* of matching elements.
> 
> It remains to be seen whether that is really what the OP wants.  It is 
> equally possible that they only want to exchange the class name in the 
> attribute value:
> 
>   let oldClassName = "Space";
>   [].forEach.call(
>     document.getElementsByClassName(oldClassName),
>     element => {
>       element.classList.remove(oldClassName);
>       element.classList.add(anotherClassName);
>     });
> 
>       [We can reasonably assume that HTML user agents that provide an 
>        ECMAScript 2015+ implementation for “let” and the arrow function
>        syntax also support the DOM4 “classList” property.  The vice-versa
>        assumption is not valid.]
> 
> Usually you would just add or remove a class name to/from the attribute 
> value instead.  A stylesheet that requires renaming of a class name in
> the attribute value for proper presentation is most certainly ill-designed.
> 

The replace image inside each span with another is working now.
See my code below.  Probably previously my problem statement were not clear.
Thanks.

var connector = function() {

// get the class
	let spaceS = document.getElementsByClassName('Space');
	
	for (s = spaceS.length - 2; s >= 0; s--) {
		console.log(s);
		try {
		spaceS[s].innerHTML = "<img src='line.png' border=0>";
		}
		catch (err) {
			consolo.log(err);
		}
	}
	
}	

[toc] | [prev] | [next] | [standalone]


#31663

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-11-10 20:37 +0100
Message-ID<XnsA6BCD1D8B523Ceejj99@194.109.6.166>
In reply to#31661
justaguy <lichunshen84@gmail.com> wrote on 10 Nov 2016 in
comp.lang.javascript: 

>> This Q is independent of the above.
>> 
>> Google "how to replace all elements classname"
>> and read the many discussions on stackoverflow!
>> 
>> Please first Google!
>> 
> 
> I did, however, query like ""how to replace all elements classname" did
> not yield satisfactory returns, thus, asking here. 

What do you mean by "not satisfactory"?
Usenet is not a restaurant were you order and pay for food.

Methinks the discussions I refer to are very, very satisfactory,
in the sense that you learn the different aspecs and the pit-falls of
the matter at hand.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31665

Fromjustaguy <lichunshen84@gmail.com>
Date2016-11-10 11:59 -0800
Message-ID<3b987e61-5066-4c4b-b34f-ad3247e67917@googlegroups.com>
In reply to#31663
On Thursday, November 10, 2016 at 2:37:50 PM UTC-5, Evertjan. wrote:
> justaguy  wrote on 10 Nov 2016 in
> comp.lang.javascript: 
> 
> >> This Q is independent of the above.
> >> 
> >> Google "how to replace all elements classname"
> >> and read the many discussions on stackoverflow!
> >> 
> >> Please first Google!
> >> 
> > 
> > I did, however, query like ""how to replace all elements classname" did
> > not yield satisfactory returns, thus, asking here. 
> 
> What do you mean by "not satisfactory"?
> Usenet is not a restaurant were you order and pay for food.
> 
> Methinks the discussions I refer to are very, very satisfactory,
> in the sense that you learn the different aspecs and the pit-falls of
> the matter at hand.
> 

I appreciate your intention and help, however, regarding this particular problem, googling has not helped me to resolve it, hence, here again.

[toc] | [prev] | [next] | [standalone]


#31666

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-11-10 21:01 +0100
Message-ID<XnsA6BCD5E61C2FEeejj99@194.109.6.166>
In reply to#31665
justaguy <lichunshen84@gmail.com> wrote on 10 Nov 2016 in
comp.lang.javascript: 

> On Thursday, November 10, 2016 at 2:37:50 PM UTC-5, Evertjan. wrote:
>> justaguy  wrote on 10 Nov 2016 in
>> comp.lang.javascript: 
>> 
>> >> This Q is independent of the above.
>> >> 
>> >> Google "how to replace all elements classname"
>> >> and read the many discussions on stackoverflow!
>> >> 
>> >> Please first Google!
>> >> 
>> > 
>> > I did, however, query like ""how to replace all elements classname"
>> > did not yield satisfactory returns, thus, asking here. 
>> 
>> What do you mean by "not satisfactory"?
>> Usenet is not a restaurant were you order and pay for food.
>> 
>> Methinks the discussions I refer to are very, very satisfactory,
>> in the sense that you learn the different aspecs and the pit-falls of
>> the matter at hand.
> 
> I appreciate your intention and help, however, regarding this particular
> problem, googling has not helped me to resolve it, hence, here again. 

Did you get a better understanding of the matter?

Remember this is not a paid help-desk.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web