ForEach loop in java script


HTML:-

 <div class="row">

                 <div class="wrapContainer">

                    <div class="music_des">

                       <figure>

                       <a href=""><img src=""  alt=""></a>

                       </figure>

                       

                       <div class="contentPart">

                       <h3><a href="#">What is Lorem Ipsum? What is Lorem Ipsum? What is Lorem Ipsum? What is Lorem Ipsum? What is Lorem Ipsum?</a>

                        </h3>


<p class="listtxt">

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but al

<span class="plusSvg">

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" class="plus" width="40" height="32" xml:space="preserve">

<style type="text/css">


</style>

<g>

<path class="" d="M5.47,38.1H0V11.9h5.47v1.77h-3.3v22.64h3.3V38.1z"></path>

<path class="" d="M32,25.35h-6.01v6h-1.98v-6h-6v-1.99h6v-6h1.98v6H32V25.35z"></path>

<path class="" d="M50,38.1h-5.46v-1.77h3.29V13.67h-3.29v-1.77H50V38.1z"></path>

</g>

</svg>


</span> 


<span class="lodHiddenText">

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" class="minSvg" width="40" height="32" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">

<style type="text/css">

</style>

<g class="st0">

<path class="" d="M6.62,40.83H0V9.17h6.62v2.14H2.63v27.38h3.99V40.83z"></path>

<path class="" d="M30.03,25.86h-9.82v-2.32h9.82V25.86z"></path>

<path class="" d="M50,40.83h-6.6v-2.14h3.98V11.31H43.4V9.17H50V40.83z"></path>

</g>

</svg>



</span>

   </p>

                   </div>

                  

                    </div>

                 </div>

                 <div class="wrapContainer">

                    <div class="music_des">

                       <figure>

                       <a href=""><img src=""  alt=""></a>

                       </figure>

                       

                       <div class="contentPart">

                       <h3><a href="#">What is Lorem Ipsum? What is Lorem Ipsum? What is Lorem Ipsum? What is Lorem Ipsum? What is Lorem Ipsum?</a>

                        </h3>


<p class="listtxt">

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but al

<span class="plusSvg">

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" class="plus" width="40" height="32" xml:space="preserve">

<style type="text/css">


</style>

<g>

<path class="" d="M5.47,38.1H0V11.9h5.47v1.77h-3.3v22.64h3.3V38.1z"></path>

<path class="" d="M32,25.35h-6.01v6h-1.98v-6h-6v-1.99h6v-6h1.98v6H32V25.35z"></path>

<path class="" d="M50,38.1h-5.46v-1.77h3.29V13.67h-3.29v-1.77H50V38.1z"></path>

</g>

</svg>


</span> 


<span class="lodHiddenText">

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" class="minSvg" width="40" height="32" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">

<style type="text/css">

</style>

<g class="st0">

<path class="" d="M6.62,40.83H0V9.17h6.62v2.14H2.63v27.38h3.99V40.83z"></path>

<path class="" d="M30.03,25.86h-9.82v-2.32h9.82V25.86z"></path>

<path class="" d="M50,40.83h-6.6v-2.14h3.98V11.31H43.4V9.17H50V40.83z"></path>

</g>

</svg>



</span>

   </p>

                   </div>

                  

                    </div>

                 </div>

                

</div>    




css:-

     html {

            font-size: 20px;

        }


        *,

        *::before,

        *::after {

            box-sizing: border-box;

            padding: 0px;

            margin: 0px;

        }


        body {

            font-family: 'Open Sans', sans-serif;

            background-color: #fff;

            font-size: 20px;

            line-height: 26px;

            font-weight: 400;

        }



        .wrapContainer {

            width: 100%;

            height: auto;

        }


        .border_cell {

            border-top: 1px solid #c5c5c5;

        }


        .border_cell.play {

            background: #ee3523;

        }


        .music_des {

            display: flex;

            padding: 17px 20px;

            flex-wrap: wrap;

            border-bottom: 1px solid #c3c3c3;

        }


        .contentPart {

            width: calc(100% - 80px);

            height: auto;

        }


        figure,

        figure img {

            max-width: 100%;

            display: block;

        }


        .music_des figure {

            margin: 0 20px 0 0;

            width: 60px;

            height: 60px;

            background-color: royalblue;

            border-radius: 4px;

        }


        .music_des figure a {

            margin: 0 20px 0 0;

            width: 60px;

            height: 60px;

        }


        .music_des figure a img {

            width: 100%;

            height: auto;

            display: block;

        }


        .music_des h3 {

            font-size: 15px;

            font-weight: 500;

            color: #000;

            line-height: 20px;

            font-family: 'Montserrat', sans-serif;

            margin: 0;

            width: calc(100% - 80px);

        }


        .music_des h3 a {

            font-size: 15px;

            font-weight: 500;

            color: #EE3223;

            line-height: 20px;

            font-family: 'Montserrat', sans-serif;

            margin: 0;

            text-decoration: none;

        }


        .border_cell.play h3 a {

            color: #fff;

        }


        .music_des p {

            font-size: 15px;

            font-weight: 500;

            color: #000;

            line-height: 20px;

            word-wrap: break-word;

        }


        .plusSvg {

            position: relative;

            top: 6px;

            cursor: pointer;

        }



        .lodHiddenText {

            display: none;

        }


        .lodHiddenText svg.minus {

            top: 11px;

            position: relative;

            cursor: pointer;

        }


        .minSvg {

            cursor: pointer;

        }


Js:-

<script type="text/javascript">

const plusSvg = document.querySelectorAll(".plusSvg");

const minSvg = document.querySelectorAll(".minSvg");

const lodHiddenText = document.querySelectorAll(".lodHiddenText");

 

    

plusSvg.forEach(function(el){

    el.addEventListener("click", function(){

//console.log(el.nextElementSibling)

        el.nextElementSibling.style.display="inline";

        //console.log(el);

        el.style.display="none";

    });

});

    

minSvg.forEach(function(pk){

pk.addEventListener("click", function(){

       //  el.previousElement.display = "none"

        

    // console.log(el.parentElement);

    pk.parentElement.style.display="none";

    // console.log(el.parentElement.previousElementSibling);

    pk.parentElement.previousElementSibling.style.display="inline-block";

    

    

});

    

});    

    

</script>


No comments:

Post a Comment