I am trying to understand the following code from this post, and I cannot find out why We use Children vs Siblings. I can understand Children can be following nested tag, but what is level for Siblings?
$('input:checkbox').on('change', function() {
if ($(this).prop('checked') === true) {
$(this).parent('div').siblings('.flex-column').children('h2.addMsg').fadeIn("fast").fadeOut(5000);
} else {
$(this).parent('div').siblings('.flex-column').children('h2.removeMsg').fadeIn("fast").fadeOut(5000);
}
});
A person with no siblings is an only child. While some circumstances can cause siblings to be raised separately (such as foster care) most societies have siblings grow up together. This causes the development of strong emotional bonds, with siblinghood considered a unique type of relationship unto itself.
Answer. A sibling is a brother or a sister. The plural is siblings, and it can refer to brothers, sisters, or a combination of both. Siblings can be any age; they are not necessarily children.
nephew. noun. a son of your brother or sister, or a son of your husband's or wife's brother or sister. Their daughter is called your niece.
There is a myth that an only child is often more selfish than someone who has siblings. People believe that they're spoiled and lonely. But the truth is: Children being their first and foremost priority, parents usually try new & innovative activities, thus spending quality time with her.
The first difference between being only child and being raised among siblings is in terms of getting and sharing stuffs, toys, etc. Obviously, being an only child means that your parents have only you to spend their money and do not have to share with anybody,...
In its simplest form, parent to child (and grandparent to grandchild) transfers are excluded from reassessment, but sibling to sibling transfers are subject to reassessment when it comes to property taxes. An exclusion occurs when an assessor does not reassess a property because the property is eligible to be excluded if the owner files a claim.
The arrival of a younger sibling means going back to the intense demands of a newborn. Obviously, there will be common denominators between all of your children, no matter what the age difference.
Because the child will be an absence of a playmate, the child may grow up as a selfish person unless they learn the idea from school or their peers. In addition, loneliness could cause the child to become depressed or emotionally disturbed. In contrast to a child who has siblings, they are raised among their sister or brother.
Just like in real life with real families, siblings are elements with the same parent element.
So if we have
<div id=1>
<div id=2>
<div id=3>
<div id=4>
</div>
The elements with IDs 2, 3, and 4 are all siblings of each other, and are children of element with ID 1.
Sibling is not just above same level it is also about same parent. Sibling is like your brother/sister in law (same parent), you are not a sibling to your classmate.
When you click the checkbox, you are children of div
use parent('div')
allowed you to target this parent,
use .siblings('.flex-column')
will target all sibling of your parent with class .flex-column
, then for each of those sibling go to their children find h2 with class addMsg
or removeMsg
.
For each do fadIn/fadeOut.
$('input:checkbox').on('change', function() {
if ($(this).prop('checked') === true) {
$(this).parent().siblings('.flex-column').children('h2.addMsg').fadeIn("fast").fadeOut(1000);
} else {
$(this).parent().siblings('.flex-column').children('h2.removeMsg').fadeIn("fast").fadeOut(1000);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="flex-column">
<input type="checkbox" />
<h2 class="addMsg">addMsg 1</h2>
<h2 class="removeMsg">removeMsg 1</h2>
</div>
<div class="flex-column">
<input type="checkbox" />
<h2 class="addMsg">addMsg 2</h2>
<h2 class="removeMsg">removeMsg 2</h2>
</div>
<span class="flex-column">
<input type="checkbox" />
<h2 class="addMsg">addMsg 3</h2>
<h2 class="removeMsg">removeMsg 3</h2>
</span>
Parent, siblings, children are the relations between the nodes(tags as in case of html)
Siblings: All the nodes which share the same parent are siblings
Children: All the nodes which the current node point to as parent are the Children nodes
e.g.
<html>
<head></head>
<body></body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With