قمت بانشاء هذا الكود في الجافاسكريبت ولكني لا استطيع تبديل الصورة
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><!-- displays site properly based on user's device --><linkrel="icon"type="image/png"sizes="32x32"href="./assets/images/favicon-32x32.png"/><title>Frontend Mentor | FAQ accordion</title><linkrel="preconnect"href="https://fonts.googleapis.com"><linkrel="preconnect"href="https://fonts.gstatic.com"crossorigin><linkhref="https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap"rel="stylesheet"><style>/* @font-face {
font-family: myFirstFont;
src:local("/assets/fonts/WorkSans-Italic-VariableFont_wght.ttf");} */*{padding:0;margin:0;box-sizing: border-box;}
body {background-color: hsla(279,100%,97%,1);background-image:url(/assets/images/background-pattern-desktop.svg);background-repeat: no-repeat;background-position: center;background-size:120%;font-family: Work Sans;}.mainImg {width:25px;}.hiding {display: flex;}.hiding img {width:50px;}.panel {padding:018px;display: none;/* background-color: white; */overflow: hidden;}.accordion {/* background-color: #eee; */color:#444;cursor: pointer;padding:18px;width:100%;border: none;text-align: left;outline: none;font-size:15px;transition:0.4s;background-color: white;display: flex;justify-content: space-between;align-items: center;}.box{width:40%;background-color: white;margin: auto;position: absolute;left:50%;top:50%;transform: translate(-50%,-50%);}.hiding{display: flex;/* justify-content: space-between; */align-items: center;}
p{text-align: left;}</style></head><body><!--div box --><!-- hiding --><divclass="hiding"></div><!-- // hiding --><divclass="box"><divclass="hiding"><imgclass="mainImg"src="/assets/images/icon-star.svg"alt=""/><h1>FAQs</h1></div><!-- question 1 --><buttonclass="accordion">Wat is Frontend Mentor, and how will it help me?
<imgclass="imgaccordion"src="/assets/images/icon-plus.svg"alt=""/></button><divclass="panel"><p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iure
aliquam fuga eligendi saepe nostrum provident sapiente dignissimos
cum labore molestiae! Reiciendis, ut. Obcaecati ipsum maiores
voluptatem qui facilis beatae ab.
</p></div><buttonclass="accordion">Wat is Frontend Mentor, and how will it help me?
<imgclass="imgaccordion"src="/assets/images/icon-plus.svg"alt=""/></button><divclass="panel"><p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iure
aliquam fuga eligendi saepe nostrum provident sapiente dignissimos
cum labore molestiae! Reiciendis, ut. Obcaecati ipsum maiores
voluptatem qui facilis beatae ab.
</p></div><buttonclass="accordion">Wat is Frontend Mentor, and how will it help me? <imgclass="imgaccordion"src="/assets/images/icon-plus.svg"alt=""/></button><divclass="panel"><p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iure
aliquam fuga eligendi saepe nostrum provident sapiente dignissimos
cum labore molestiae! Reiciendis, ut. Obcaecati ipsum maiores
voluptatem qui facilis beatae ab.
</p></div><buttonclass="accordion">Wat is Frontend Mentor, and how will it help me? <imgclass="imgaccordion"src="/assets/images/icon-plus.svg"alt=""/></button><divclass="panel"><p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iure
aliquam fuga eligendi saepe nostrum provident sapiente dignissimos
cum labore molestiae! Reiciendis, ut. Obcaecati ipsum maiores
voluptatem qui facilis beatae ab.
</p></div></div><divclass="attribution"><ahref="https://www.frontendmentor.io?ref=challenge"target="_blank">Frontend Mentor</a><div>Coded by <ahref="#">HemaFars</a></div></div></body><script>var acc = document.getElementsByClassName("accordion");var i;var img = document.getElementsByClassName("imgaccordion");for(i =0; i < acc.length; i++){
acc[i].addEventListener("click",function(){this.classList.toggle("active");var panel =this.nextElementSibling;if(panel.style.display ==="block"){
panel.style.display ="none";
img.src =="assets/images/icon-minus.svg"}else{
panel.style.display ="block";}if(img.src ==="assets/images/icon-plus.svg"){
img.src ="assets/images/icon-minus.svg"}else
img.src ="assets/images/icon-plus.svg"});}</script></script></html>
برجاء المساعدة وتوضيح سبب عدم استطاعتي علما بانني قد درست اساسيات جافاسكريبت وHTML , CSS
السؤال
Ibrahim Fares2
قمت بانشاء هذا الكود في الجافاسكريبت ولكني لا استطيع تبديل الصورة
برجاء المساعدة وتوضيح سبب عدم استطاعتي علما بانني قد درست اساسيات جافاسكريبت وHTML , CSS
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.