Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26911
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: using 'this' to reference an 'a' element |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <7d66ec0e-ee46-49d2-9f65-4c1c185c1bd5@googlegroups.com> <171078b9-3fd2-4a9f-a860-627f5e3e946a@googlegroups.com> |
| Date | 2015-02-23 21:59 +0100 |
| Message-ID | <XnsA44ADFC969718eejj99@194.109.133.133> (permalink) |
JeffG <jeffgutsell@fuse.net> wrote on 23 feb 2015 in comp.lang.javascript:
> On Thursday, February 19, 2015 at 5:20:59 PM UTC-5, JeffG wrote:
>> I am developing an HTML5 site and recently was surprised and puzzled by
>> a problem I encountered when passing a "this" object to a function. I
>> would like to understand what is happening here.
>>
>> I want to use the "this" object to get the parent element.
>>
>> This code works:
>> HTML:
>> <li><a href="#" onclick="MyFuc(this, 'anID');void(0);"> ...
>> Script:
>> function MyFunc(alink, anelem) {
>> var ParElem = alink.parentNode;
>> //...
>> }
>> This code does NOT work:
>> HTML:
>> <li><a href="javascript:MyFuc(this, 'anID');void(0);"> ...
>>
>> I've attempted to test what's different, and it seems that "this" is
>> referencing something other than the "a" element.
>>
>> Help!
>
> Thank you very much. This helps a lot
It seems by the quoting you thanking yourself.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
using 'this' to reference an 'a' element JeffG <jeffgutsell@fuse.net> - 2015-02-19 14:20 -0800
Re: using 'this' to reference an 'a' element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-02-19 23:40 +0100
Re: using 'this' to reference an 'a' element JeffG <jeffgutsell@fuse.net> - 2015-02-23 11:12 -0800
Re: using 'this' to reference an 'a' element "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-02-23 21:59 +0100
csiph-web