Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <77765214.TbjAYTqD3W@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 22 Nov 2011 01:12:19 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit 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> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 56 NNTP-Posting-Date: 22 Nov 2011 01:12:19 CET NNTP-Posting-Host: b668e72a.newsspool3.arcor-online.net X-Trace: DXC=D7WUKK3n6\dEB;5>eE0T7mMcF=Q^Z^V3h4Fo<]lROoRa8kF 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 ? 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