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


Groups > comp.lang.javascript > #21274

Re: What is the point to use the setAttribute method when there is better way

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From "Tony Johansson" <johansson.andersson@telia.com>
Newsgroups comp.lang.javascript
Subject Re: What is the point to use the setAttribute method when there is better way
Date Thu, 12 Sep 2013 02:31:05 +0200
Organization A noiseless patient Spider
Lines 40
Message-ID <l0r215$176$1@dont-email.me> (permalink)
References <l0pu7u$j9e$1@dont-email.me> <2o2qwle7mok$.1b5nmztiitach$.dlg@40tude.net>
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding 7bit
Injection-Date Thu, 12 Sep 2013 00:31:33 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="8fdc2b5af81c338deb7045fc6c39b0e2"; logging-data="1254"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zFUkHzNy9chvfAY78+9f0"
X-MimeOLE Produced By Microsoft MimeOLE V6.0.6002.18463
In-Reply-To <2o2qwle7mok$.1b5nmztiitach$.dlg@40tude.net>
X-Newsreader Microsoft Windows Mail 6.0.6002.18197
Cancel-Lock sha1:0mxYq72HpdAR4nFGitQkccNfNG0=
X-Priority 3
X-MSMail-Priority Normal
Xref csiph.com comp.lang.javascript:21274

Show key headers only | View raw


So in this case it's no point to use setAttributes

//Tony

"JJ" <duh@nah.meh> skrev i meddelandet 
news:2o2qwle7mok$.1b5nmztiitach$.dlg@40tude.net...
> On Wed, 11 Sep 2013 16:20:23 +0200, Tony Johansson wrote:
>> Here I have two alternative setImage1 and setImage2 to add a value to the
>> scr attribute and the alt attribute for the dieImg object.
>> I find the second solution setImage2  much easier then the first one.
>> So my question is if it's any point to use the first solution where you 
>> use
>> the setAttribute metod
>> The result from these two function is the same.
>> function setImage1( dieImg )
>>          {
>>              var dieValue = Math.floor(1 + Math.random() * 6);
>>             dieImg.setAttribute( "src", "img/die" + dieValue + ".png" );
>>
>>             dieImg.setAttribute( "alt",  "die image with " + dieValue + "
>> spot(s)" );
>>          } // end function setImage
>>
>> function setImage2( dieImg )
>>          {
>>              var dieValue = Math.floor(1 + Math.random() * 6);
>>              dieImg.src = "img/die" + dieValue + ".png"
>>
>>             dieImg.alt = "die image with " + dieValue + " spot(s)" );
>>          } // end function setImage
>
> That's because an image element is an HTMLImageElement object, and is 
> based
> on HTMLElement object. So, HTMLImageElement is inherited with all
> HTMLElement object properties.
>
> HTMLElement is inherited with all Element object properties.
> Element is inherited with all Node object properties.
> Node is inherited with all Object object properties. 

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


Thread

What is the point to use the setAttribute method when there is better way "Tony Johansson" <johansson.andersson@telia.com> - 2013-09-11 16:20 +0200
  Re: What is the point to use the setAttribute method when there is better way JJ <duh@nah.meh> - 2013-09-12 05:05 +0700
    Re: What is the point to use the setAttribute method when there is better way "Tony Johansson" <johansson.andersson@telia.com> - 2013-09-12 02:31 +0200
      Re: What is the point to use the setAttribute method when there is better way Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-09-12 11:34 +0200

csiph-web