Such as:
<div class="mostOut">
<div class="a">
<h3 class="b"></h3>
<div class="d"></div>
</div>
</div>
And how can I apply css style to the children of "moustOut"
at the same time.E.g:
with one click event
.the css('opacity',1)
could apply to the "a","b","d"
at the same time.Or ,exclude "b"
.
When you group CSS selectors, you apply the same styles to several different elements without repeating the styles in your stylesheet. Instead of having two, three, or more CSS rules that do the same thing (set the color of something to red, for example), you use a single CSS rule that accomplishes the same thing.
How to select all children of an element except the last child using CSS? When designing and developing web applications, sometimes we need to select all the child elements of an element except the last element. To select all the children of an element except the last child, use :not and :last-child pseudo classes.
Approach: Use the :not(selector), also known as negation pseudo-class which takes a simple selector as an argument and allows you to style all the elements except the element specified by the selector.
a little less code
$('.mostOut').click(function()
{
$(this).children("*").css('opacity', 1);
});
and exclude ".b"
$('.mostOut').click(function()
{
$(this).children("*").not(".b").css('opacity', 1);
});
or alternatively if its not the opacity causing the hidden/none
$('.mostOut').click(function()
{
$(this).children("*").show();
});
This might be a dirty solution, but it should work:
$('.mostOut').click(function()
{
$(this).find('*').each(function()
{
$(this).css('opacity', 1);
});
});
For excluding all but the b
element, try this:
$('.mostOut').click(function()
{
$(this).find('*').not('.b').each(function()
{
$(this).css('opacity', 1);
});
});
Play with the code, as I just typed this off of the top of my head, so I'm not guaranteeing that it will work.
Good luck!
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