Questions tagged [children]

Children is the set of all nodes within a hierarchical data structure which have a node above them.

1638 questions
270
votes
5 answers

Best way to get child nodes

I was wondering, JavaScript offers a variety of methods to get the first child element from any element, but which is the best? By best, I mean: most cross-browser compatible, fastest, most comprehensive and predictable when it comes to behaviour. A…
Elias Van Ootegem
  • 74,482
  • 9
  • 111
  • 149
235
votes
7 answers

jquery if div id has children

This if-condition is what's giving me trouble: if (div id=myfav has children) { do something } else { do something else } I tried all the following: if ( $('#myfav:hasChildren') ) { do something } if ( $('#myfav').children() ) { do something…
Chris
  • 8,736
  • 18
  • 49
  • 56
189
votes
18 answers

Career day in kindergarten: how to demonstrate programming in 20 minutes?

Original Question I was invited to the kindergarten group of my elder daughter to talk and answer the kids' questions about my profession. There are 26 kids of age 4-6 in the group, plus 3 teachers who are fairly scared of anything related to…
Péter Török
  • 114,404
  • 31
  • 268
  • 329
121
votes
11 answers

Loop through childNodes

I'm trying to loop through childNodes like this: var children = element.childNodes; children.forEach(function(item){ console.log(item); }); However, it output Uncaught TypeError: undefined is not a function due to forEach function. I also try…
user3828771
  • 1,603
  • 3
  • 14
  • 14
77
votes
4 answers

Jquery $(this) Child Selector

I'm using this: jQuery('.class1 a').click( function() { if ($(".class2").is(":hidden")) { $(".class2").slideDown("slow"); } else { $(".class2").slideUp(); } }); On page structure:
text
Orbalon
77
votes
9 answers

parent & child with position fixed, parent overflow:hidden bug

I don't know if there is an issue, but I was wondering why the overflow:hidden does not function on fixed parent/children element. Here's an example: CSS and HTML: .parent{ position:fixed; overflow:hidden; width:300px; height:300px; …
kirkas
  • 1,749
  • 2
  • 12
  • 22
70
votes
4 answers

Styling nested elements in WPF

Suppose you have a nested element structure, for example a ContextMenu with MenuItems: ... You can easily apply styles…
gix
  • 5,737
  • 5
  • 34
  • 40
58
votes
7 answers

Angular 2 routing redirect to with child routes

I am a newbie in Angular 2. I want to create isolated modules for every part of my app. For example I created the AuthModule with default component - AuthComponent which contain a router-outlet for his child components (SignIn or SignUp). So I want…
Timofey Orischenko
  • 1,148
  • 1
  • 9
  • 12
56
votes
3 answers

How to select a node's first child name? XPath

I have an XML from which I have to select the name of the child of one of the nodes. I'm kind of a beginner in this, so I didn't find the Xpath expression to do it. I know the level of the node Example Name from /Employee/Department/ but…
Jaq
  • 561
  • 1
  • 4
  • 3
50
votes
3 answers

css all divs vs direct child divs

I have this structure:
ddddddd
pppppppppp
pppppppppp
ddddddd
I want to put borders on the divs that contain ddddddd, and I want to set…
Naor
  • 23,465
  • 48
  • 152
  • 268
45
votes
46 answers

Suggestions on starting a child programming

What languages and tools do you consider a youngster starting out in programming should use in the modern era? Lots of us started with proprietary Basics and they didn't do all of us long term harm :) but given the experiences you have had since…
sparkes
  • 19,343
  • 5
  • 39
  • 46
44
votes
5 answers

How can I get the child windows of a window given its HWND?

I have the handle for a given window. How can I enumerate its child windows?
Yuriy Faktorovich
  • 67,283
  • 14
  • 105
  • 142
43
votes
11 answers

How do I make this loop all children recursively?

I have the following: for (var i = 0; i < children.length; i++){ if(hasClass(children[i], "lbExclude")){ children[i].parentNode.removeChild(children[i]); } }; I would like it to loop through all children's children, etc (not just the…
Matrym
  • 16,643
  • 33
  • 95
  • 140
39
votes
31 answers

Suitable environment for a 7 year old

My 7 year old would like to learn, how to program? (his idea not mine, and he does things in the outside world. So, I am not too worried from that point of view. He already went so far as to take a game programming book out of my office to read at…
TofuBeer
  • 60,850
  • 18
  • 118
  • 163
38
votes
6 answers

How to select first child?

How do I select the first div in these divs (the one with id=div1) using first child selectors?
1 This one
2
3…
sameold
  • 18,400
  • 21
  • 63
  • 87
1
2 3
99 100