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


Groups > comp.lang.javascript > #8518

Re: Jquery to create 2 or multiple events in .change

Message-ID <77765214.TbjAYTqD3W@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-11-22 01:12 +0100
Subject Re: Jquery to create 2 or multiple events in .change
Newsgroups comp.lang.javascript
References <4eca261b$0$1382$4fafbaef@reader2.news.tin.it> <8704ba53-b8ef-4e8a-8d1d-886bd84a986d@a16g2000yqk.googlegroups.com> <jaejha$i1j$1@dont-email.me>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Gregor Kofler wrote:

> Am 2011-11-21 14:31, Scott Sauyet meinte:
>> Jesolo Sun wrote:
>> […]
>>>   $("select#stampa").change(function(){
>>>     var stampa = $("select#stampa option:selected").attr('value');
>>>     // ...
>>>   });
>> 
>> This is cleaner, and I think it would work equally well:
>> 
>>     $("select#stampa").change(function(){
>>       var stampa = $(this).val();
>>       // ...
>>     }

Those two approaches are _not_ equivalent, and the second one would 
certainly _not_ work equally well.  We have discussed the difference between 
the value of a selected `option' and the value of a `select' so often here 
that I have lost count.

> Out of curiosity:
> 
> Wouldn't
> 
> $("select#stampa").change(function(){
>   var stampa = this.value;
> }
> 
> suffice?

For that matter, wouldn't

  document.getElementById("stampa").onchange = function () {
    var stampa = this.value;
  };

or even

  <select name="stampa" onchange="…">
    …
  </select>

?

Answer: Nooo.  Neither wouldn't be k€wL enough!!" (far too efficient and 
compatible ;-))


PointedEars
-- 
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

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


Thread

Jquery to create 2 or multiple events in .change  "Jesolo Sun" <gala@tiscali.it> - 2011-11-21 11:21 +0100
  Re: Jquery to create 2 or multiple events in .change Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-21 05:31 -0800
    Re: Jquery to create 2 or multiple events in .change Gregor Kofler <usenet@gregorkofler.com> - 2011-11-21 23:32 +0100
      Re: Jquery to create 2 or multiple events in .change Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-22 01:12 +0100
        Re: Jquery to create 2 or multiple events in .change Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-22 06:54 -0800
      Re: Jquery to create 2 or multiple events in .change Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-23 18:16 -0800

csiph-web