jQuery first-child: Select all that are the first child of their parent.
A simple example in which I used first child to open first block of each accordion panel dynamically.
In a project I have an accordion panel in which I created multiple sub-accordion and I have to open first block of each sub-accordion and rest hide.
If we give div:first it will show only first block of first sub-accordion. So I used first-child selector which served my purpose.
A simple example in which I used first child to open first block of each accordion panel dynamically.
In a project I have an accordion panel in which I created multiple sub-accordion and I have to open first block of each sub-accordion and rest hide.
If we give div:first it will show only first block of first sub-accordion. So I used first-child selector which served my purpose.
<script type="text/javascript">
$(function() {
$(".subaccordian div:first-child").show();
});
</script>
No comments:
Post a Comment