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


Groups > comp.lang.javascript > #19415

Re: javascript to test if anchor tag is contained within div tag

Message-ID <3526876.2WAoL8vqck@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-04-23 10:07 +0200
Subject Re: javascript to test if anchor tag is contained within div tag
Newsgroups comp.lang.javascript
References <3191a789-89f0-4740-b9cc-77719dac2f60@googlegroups.com> <71e89685-4598-4b92-86d4-f01253a846f9@googlegroups.com> <85d30fa5-56d9-456a-9c48-67ce4b36bedf@googlegroups.com> <30b40f71-e1fa-40a9-a246-0dfb07ba3a2b@googlegroups.com>

Show all headers | View raw


charles.e.finkenbiner@gmail.com wrote:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please get a real name.

> Well, what sounded easy is turning into a pain for me.  I have very basic
> HTML and javascript skills so please bear with me.
> 
> Based on my sample HTML code above anchor.parentNode.tagName only returns
> the element LI.  Also, since I am only looping the anchors I never seem to
> reach any DIV tag.

/Element/, _not_ tag.   In a document, elements are nested, they have 
attributes and content (which may be text or other elements).  That is what 
forms a document *tree* structure.  *Every* node that is not at the root 
level has a parent element node – like a leaf has a twig, a twig has a 
branch, a branch has a trunk, and a trunk has a root it sits on.  You can 
retrieve a reference to an element node's parent (element) node by using the 
“parentNode” property (whose value is “null” at the root level).

So, in real life, what do you do when you want to get from the leaf to the 
branch its twig sits on?  What do you do when you are sitting on a twig and 
want to get from the twig to the trunk, or to the root?

And not all elements can be nested in all other ones.  The “div” element 
cannot be nested *directly* in a “ul” element, that is, as its /child/ 
element.  The child elements of “ul” elements must be “li” elements.  So 
before you go any further, you must fix your markup.  You must decide on 
HTML code that suits your purpose *and* is Valid: <http://validator.w3.org/>

> To Danny,

This is NetNews, not private e-mail.  Skip the “to $Person” thing unless you 
really only want answers from $Person.  Do not follow Danny's bad example.

> […]
> So, does this mean I am not coding the HTML or javascript correctly? 

It means that you are programming and posting without thought, and you are 
listening to people who do not really have a clue.  So the outcome is 
necessarily rarely positive.  You need to understand the underlying theory, 
the concepts, first, and you need to structure your thinking, considering 
carefully the current situation, the target, and *how* you could get to the 
target.  Just dabbling around will _not_ get you there.

BTW, there is no javascript: <http://PointedEars.de/es-matrix>.

> Maybe a little example will help me.

Maybe not.  What good is an example, what good is an explanation, that you 
do not understand because you are lacking the minimum clue?

Maybe reading the FAQ, and the references to documentation; following those 
references, and *reading* the documentation, *before* posting, will help 
you.  After all, that is why we put it there.  So why do you not use it?

<http://jibbering.com/faq/>
<http://PointedEars.de/faq>

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

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


Thread

javascript to test if anchor tag is contained within div tag charles.e.finkenbiner@gmail.com - 2013-04-22 08:15 -0700
  Re: javascript to test if anchor tag is contained within div tag Danny <dann90038@gmail.com> - 2013-04-22 13:18 -0700
  Re: javascript to test if anchor tag is contained within div tag Danny <dann90038@gmail.com> - 2013-04-22 13:22 -0700
    Re: javascript to test if anchor tag is contained within div tag charles.e.finkenbiner@gmail.com - 2013-04-22 17:34 -0700
      Re: javascript to test if anchor tag is contained within div tag charles.e.finkenbiner@gmail.com - 2013-04-22 20:31 -0700
        Re: javascript to test if anchor tag is contained within div tag Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-23 10:07 +0200
  Re: javascript to test if anchor tag is contained within div tag Danny <dann90038@gmail.com> - 2013-04-23 11:50 -0700
  Re: javascript to test if anchor tag is contained within div tag CharlesEF <charles.e.finkenbiner@gmail.com> - 2013-04-24 01:51 -0700
    Re: javascript to test if anchor tag is contained within div tag Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-04-24 12:42 -0600
      Re: javascript to test if anchor tag is contained within div tag CharlesEF <charles.e.finkenbiner@gmail.com> - 2013-04-24 14:40 -0700

csiph-web