Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Unable to get the "children" of an element

 
Bartender
Posts: 2900
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My Requirement is to find all "Immediate" children of a Div with Id as "stackContainer" having the class as "stack"

if i am able to get the collection as an array, i could loop through it and get the class name of each element,
What i thought was browsers had an inbuilt functionality

Here is what i have attempted so far :




Outputs :

IE7 :
first alert: 2
second alert: children 2

Firefox :
first alert: 5
No second alert

Chrome :
first alert: 5
second alert: children 2

Going out of the topic, why do browsers even differ in implementations of Javascript ?? !!!
or am i using the wrong collection object ?

Actually, i am thinking of making a stack like control (similar to outlook's Personal/calender/todo @ LHS) however, i got stuck up in Step 1 !!
I am a newbie javascript developer
 
salvin francis
Bartender
Posts: 2900
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hierarchy :

stackContainer > stack > header + data
 
salvin francis
Bartender
Posts: 2900
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
another thing, in the above example,
given that stackContainer contains (considering nesting):

stack+header+data+stack+header+data =6 elements,
why does the output for child nodes say 5 ??
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.howtocreate.co.uk/tutorials/javascript/dombasics

Eric
 
salvin francis
Bartender
Posts: 2900
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm

so its

textNode + stack + textNode + stack + textNode = 5 elements

Wonder why IE not count the textNodes,

Ne ways....
I will move up the step 2 now >> hiding data within stack elements, i hope i dont get stuck up thre


here is my approach:


1. User takes mouse over stack element
2. If stack is open, do nothing
3. If stack is not open, open the stack and close others by reducing size till its 0% (for animation)
4. I will post code here if it works....
 
salvin francis
Bartender
Posts: 2900
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As promised, for all those who want an expanding container ......





code optimisations welcome, suggestions welcome, criticism welcome.

i was thinking of animating it, but i couldnt figure out a way to get a hidden div's height.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic