Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8527
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Jquery to create 2 or multiple events in .change |
| Date | 2011-11-22 06:54 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <2e061c10-c38b-4d04-96e7-d33643ccade9@gi1g2000vbb.googlegroups.com> (permalink) |
| References | <4eca261b$0$1382$4fafbaef@reader2.news.tin.it> <8704ba53-b8ef-4e8a-8d1d-886bd84a986d@a16g2000yqk.googlegroups.com> <jaejha$i1j$1@dont-email.me> <77765214.TbjAYTqD3W@PointedEars.de> |
Thomas 'PointedEars' Lahn wrote:
> 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.
Really? I'm surprised because I don't recall it being discussed in
the two years I've been reading. I certainly don't read every post,
and could well have missed one, but if it were so common, I would have
thought I'd have seen it. Odd.
Except in the case of multiple selections, I don't know what the
difference would be. Would you be willing to explain? In the case of
multiple selection, the approach I suggested would return an array of
the selected values, whereas the original would only return the first
one. I think that would be an improvement, but YMMV. What other
differences are there?
> [ ... ]
> For that matter, wouldn't
>
> document.getElementById("stampa").onchange = function () {
> var stampa = this.value;
> };
> [ suffice?]
>
> Answer: Nooo. Neither wouldn't be k€wL enough!!" (far too efficient and
> compatible ;-))
Am I right that this would only show at most the first selection in
multi-select mode? I know that's the case in the browsers I've
tested, but I have only tested a few recent browsers. And in IE8,
would that even show any value?
-- Scott
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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