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


Groups > comp.lang.javascript > #37890

Re: input type="color"

Path csiph.com!3.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder7.news.weretis.net!news.mb-net.net!open-news-network.org!.POSTED.2.226.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: input type="color"
Supersedes <5321457.DvuYhMxLoT@PointedEars.de>
Date Thu, 28 Nov 2019 18:52:18 +0100
Organization PointedEars Software (PES)
Lines 40
Message-ID <5564197.lOV4Wx5bFT@PointedEars.de> (permalink)
References <EuOdnX4YMNxVk0vAnZ2dnUU7-LfNnZ2d@westnet.com.au> <h3pnucFua1sU1@mid.individual.net> <qr8fig$9qm$1@dont-email.me> <XnsAB0F86568E313eejj99@194.109.6.166> <-oydnbqUVL4VAkXAnZ2dnUU7-dnNnZ2d@westnet.com.au> <XnsAB108C3B8DBBEeejj99@194.109.6.166> <DuWdnZpAVtpqKETAnZ2dnUU7-TXNnZ2d@westnet.com.au> <XnsAB1167E5E72A1eejj99@194.109.6.166> <ibudnSCvzuOJeUfAnZ2dnUU7-Q_NnZ2d@westnet.com.au>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
Injection-Info gwaiyur.mb-net.net; posting-host="2.226.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch:178.197.226.2"; logging-data="16654"; mail-complaints-to="abuse@open-news-network.org"
User-Agent KNode/4.14.10
Cancel-Key sha1:VqbhC9uZxD31XiijWx0qCn+udOI=
Cancel-Lock sha1:/kmK2FjYPSauzY3X2aeMZlkiQdQ=
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H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MqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Xref csiph.com comp.lang.javascript:37890

Show key headers only | View raw


Andrew Poulos wrote:

> On 24/11/2019 8:12 pm, Evertjan. wrote:
>> <style>
>> #showColour {width:120px;height:50px;border:black 2px solid;}
>> </style>
>> <div id='showColour'></div>
>> <div id='showColourString'></div>
>> <br><br>
>> <input id='getColour' value='#'>
>> <script>
>> const getColour = document.querySelector('#getColour');
>> const showColour = document.querySelector('#showColour');
>> const showColourString = document.querySelector('#showColourString');

This is much more efficient when written as follows:

  const getColour = document.getElementById('getColour');
  const showColour = document.getElementById('showColour');
  const showColourString = document.getElementById('showColourString');

See also: <https://gist.github.com/chitsaou/3066411>

Also, using these variable identifiers and therefore the IDs is unwise at 
best.  Those (verb + object) are identifiers that should only be used for 
*functions* and *methods*.
 
>> getColour.addEventListener("keyup", function() {
>> if (this.value.length == 4 || this.value.length == 7) {
>> showColour.style.backgroundColor = this.value;
>> showColourString.innerHTML =  this.value;

  showColourString.textContent = this.value;

But see above.

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

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: input type="color" Andrew Poulos <ap_prog@hotmail.com> - 2019-11-25 07:12 +1100
  Re: input type="color" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-11-28 18:52 +0100

csiph-web