Received: by 10.224.183.13 with SMTP id ce13mr4524460qab.4.1349318600142; Wed, 03 Oct 2012 19:43:20 -0700 (PDT) X-BeenThere: mootools-users@googlegroups.com Received: by 10.224.101.68 with SMTP id b4ls4075444qao.0.gmail; Wed, 03 Oct 2012 19:43:17 -0700 (PDT) Received: by 10.224.183.13 with SMTP id ce13mr4524422qab.4.1349318597815; Wed, 03 Oct 2012 19:43:17 -0700 (PDT) Received: by 10.224.183.13 with SMTP id ce13mr4524421qab.4.1349318597801; Wed, 03 Oct 2012 19:43:17 -0700 (PDT) Return-Path: Received: from rproxy1-a.cypressintegrated.com (rproxy1-a.cypressintegrated.com. [69.28.242.152]) by gmr-mx.google.com with ESMTPS id a27si1214237qck.3.2012.10.03.19.43.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Oct 2012 19:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of sa...@figureone.com designates 69.28.242.152 as permitted sender) client-ip=69.28.242.152; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of sa...@figureone.com designates 69.28.242.152 as permitted sender) smtp.mail=sa...@figureone.com Received: from localhost ([192.168.87.152]) by rproxy1-a.cypressintegrated.com (Brand New Heavy v1.0) with ASMTP id OMV89517 for ; Wed, 03 Oct 2012 22:43:17 -0400 Date: Wed, 3 Oct 2012 22:42:18 -0400 From: Sanford Whiteman X-Priority: 3 (Normal) Message-ID: <411104062.20121003224218@figureone.com> To: Hamburger Subject: Re: [Moo] Do I have to check that an element exsist to get their properties? In-Reply-To: <22f15b7f-bcb4-40a9-9837-e654ab471e65@googlegroups.com> References: <22f15b7f-bcb4-40a9-9837-e654ab471e65@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > or is there a shorter other way to do this. var defaultanchor = new Element('a'); ... later ... var alwaysfindanhref = this.getElement("a") || defaultanchor.get("href"); If this.getElement('a) finds something in the DOM, you get its href. If this.getElement has no result, you get a null (or, if you set an href when creating defaultelement, that'll be your default result). Note that you can use this concept in one line if somehow mandatory... var alwaysfindanhref = this.getElement("a") || new Element("a").get("href"); ... but that's creating a new Element every time, which uses memory. -- Sandy