اذهب إلى المحتوى

السؤال

نشر (معدل)

السلام عليكم.

الرجاء التوضيح في تعطل الشيفرة أثناء تنفيذ if statement.

شيفرة الجافاسكريبت:

const iconsBtn            = document.querySelectorAll('.card-icon ')

const teamInfo            = document.querySelectorAll('.team-info')

const changeBackground    = document.querySelectorAll('.change-background ')

// console.log(iconsBtn)

for (let i = 0; i < iconsBtn.length; i++) {



    iconsBtn[i].innerHTML = `<i class="fa-solid fa-circle-plus"></i>`

    // console.log(iconsBtn[i])

    iconsBtn[i].addEventListener('click', ()=>{

       

        if (iconsBtn[i].innerHTML = `<i class="fa-solid fa-circle-plus"></i>`){

            iconsBtn[i].innerHTML =`<i class="fa-solid fa-circle-minus"></i>`

            teamInfo[i].classList.add('team-info-change')

            changeBackground[i].classList.add('change-background-active')

        } else{

            iconsBtn[i].innerHTML =`<i class="fa-solid fa-circle-plus"></i>`

            teamInfo[i].classList.remove('team-info-change')

            changeBackground[i].classList.remove('change-background-active')

            // console.log("HELLO");

        }



    })



}


ملاحظة: يتعطل تشغيل الشيفرة بداية من else

console لايظهر أي خطأ

لمزيد التوضيح إليكم شيفرة html

<div class="team-container">

        <div class="team-card">

            <img src="./img/team-member-1.jpg" alt="">

            <h4>John Doe</h4>

            <span>Web-Developer</span>

            <div class="card-icon">

                <!-- <i class="fa-solid fa-circle-plus"></i> -->

                <!-- <i class="fa-solid fa-circle-minus"></i> -->

            </div>

            <div class="team-info">

                <h3>About Me</h3>

                <p>

                    Lorem ipsum dolor sit amet consectetur adipisicing elit.

                    Reprehenderit obcaecati blanditiis aspernatur ab doloribus

                    optio nesciunt adipisci fugiat quia veritatis doloremque tempore

                    ipsum sunt atque exercitationem perspiciatis,

                    beatae aliquam voluptates perferendis.

                </p>

                <h3>Skills</h3>

                <p>

                    Javascript<br>

                    Java<br>

                    Python<br>

                    MySql

                </p>

            </div>

            <div class="change-background "></div>

        </div>

        <div class="team-card">

            <img src="./img/team-member-2.jpg" alt="">

            <h4>John Doe</h4>

            <span>Front-End-Developer</span>

            <div class="card-icon">

                <!-- <i class="fa-solid fa-circle-plus"></i> -->

                <!-- <i class="fa-solid fa-circle-minus"></i> -->

            </div>

            <div class="team-info">

                <h3>About Me</h3>

                <p>

                    Lorem ipsum dolor sit amet consectetur adipisicing elit.

                    Reprehenderit obcaecati blanditiis aspernatur ab doloribus

                    optio nesciunt adipisci fugiat quia veritatis doloremque tempore

                    ipsum sunt atque exercitationem perspiciatis,

                    beatae aliquam voluptates perferendis.

                </p>

                <h3>Skills</h3>

                <p>

                    Javascript<br>

                    Java<br>

                    Python<br>

                    MySql

                </p>

            </div>

            <div class="change-background "></div>

        </div>

        <div class="team-card">

            <img src="./img/team-member-3.jpg" alt="">

            <h4>John Doe</h4>

            <span>Back-End-Developer</span>

            <div class="card-icon">

                <!-- <i class="fa-solid fa-circle-plus"></i> -->

                <!-- <i class="fa-solid fa-circle-minus"></i> -->

            </div>

            <div class="team-info">

                <h3>About Me</h3>

                <p>

                    Lorem ipsum dolor sit amet consectetur adipisicing elit.

                    Reprehenderit obcaecati blanditiis aspernatur ab doloribus

                    optio nesciunt adipisci fugiat quia veritatis doloremque tempore

                    ipsum sunt atque exercitationem perspiciatis,

                    beatae aliquam voluptates perferendis.

                </p>

                <h3>Skills</h3>

                <p>

                    Javascript<br>

                    Java<br>

                    Python<br>

                    MySql

                </p>

            </div>

            <div class="change-background "></div>

        </div>

    </div>

 

تم التعديل في بواسطة Hassan Hedr
تنسيق الشيفرة

Recommended Posts

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...