{"id":82429,"date":"2024-11-03T09:28:02","date_gmt":"2024-11-03T05:58:02","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/image-slider-using-html-css-and-javascript-coding-httpswwwinstagramcomwebstreetcode-1lb3\/"},"modified":"2024-11-03T09:28:02","modified_gmt":"2024-11-03T05:58:02","slug":"image-slider-using-html-css-and-javascript-coding-httpswwwinstagramcomwebstreetcode-1lb3","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/image-slider-using-html-css-and-javascript-coding-httpswwwinstagramcomwebstreetcode-1lb3\/","title":{"rendered":"\u0627\u0633\u0644\u0627\u06cc\u062f\u0631 \u062a\u0635\u0648\u06cc\u0631 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 html css \u0648 \u06a9\u062f\u06af\u0630\u0627\u0631\u06cc \u062c\u0627\u0648\u0627 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a https:\/\/www.instagram.com\/webstreet_code\/ &#8211; \u0627\u0646\u062c\u0645\u0646 DEV"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang <\/p>\n<p>    Image Background Selector<\/p>\n<p> {<br \/>\n        thumbnails.forEach((thumb, i) => {<br \/>\n            thumb.classList.toggle(&#8216;active-thumbnail&#8217;, i === index);<br \/>\n        });<br \/>\n        background.style.backgroundImage = `url(${thumbnails[index].getAttribute(&#8216;data-bg&#8217;)})`;<br \/>\n    };<\/p>\n<p>    \/\/ Left arrow click event<br \/>\n    document.getElementById(&#8216;left&#8217;).onclick = () => {<br \/>\n        currentIndex = (currentIndex &#8211; 1 + thumbnails.length) % thumbnails.length;<br \/>\n        updateBackground(currentIndex);<br \/>\n    };<\/p>\n<p>    \/\/ Right arrow click event<br \/>\n    document.getElementById(&#8216;right&#8217;).onclick = () => {<br \/>\n        currentIndex = (currentIndex + 1) % thumbnails.length;<br \/>\n        updateBackground(currentIndex);<br \/>\n    };<\/p>\n<p>    \/\/ Thumbnail click event to update the background<br \/>\n    thumbnails.forEach((thumb, i) => {<br \/>\n        thumb.onclick = () => {<br \/>\n            currentIndex = i;<br \/>\n            updateBackground(i);<br \/>\n        };<br \/>\n    });<\/p>\n<p>    \/\/ Set initial background<br \/>\n    updateBackground(currentIndex);<br \/>\n]]><\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<div data-article-id=\"2073656\" id=\"article-body\">\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\n\n\n    <meta charset=\"UTF-8\"\/>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\/>\n    <title>Image Background Selector<\/title>\n    \n\n\n\n\n\n\n\n<script><![CDATA[\n    const background = document.getElementById('background');\n    const thumbnails = document.querySelectorAll('.thumbnails img');\n    let currentIndex = 0;\n\n    \/\/ Function to update the background based on the active thumbnail\n    const updateBackground = (index) => {\n        thumbnails.forEach((thumb, i) => {\n            thumb.classList.toggle('active-thumbnail', i === index);\n        });\n        background.style.backgroundImage = `url(${thumbnails[index].getAttribute('data-bg')})`;\n    };\n\n    \/\/ Left arrow click event\n    document.getElementById('left').onclick = () => {\n        currentIndex = (currentIndex - 1 + thumbnails.length) % thumbnails.length;\n        updateBackground(currentIndex);\n    };\n\n    \/\/ Right arrow click event\n    document.getElementById('right').onclick = () => {\n        currentIndex = (currentIndex + 1) % thumbnails.length;\n        updateBackground(currentIndex);\n    };\n\n    \/\/ Thumbnail click event to update the background\n    thumbnails.forEach((thumb, i) => {\n        thumb.onclick = () => {\n            currentIndex = i;\n            updateBackground(i);\n        };\n    });\n\n    \/\/ Set initial background\n    updateBackground(currentIndex);\n]]><\/script>\n\n\n\n\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang Image Background Selector { thumbnails.forEach((thumb, i) => { thumb.classList.toggle(&#8216;active-thumbnail&#8217;, i === index); }); background.style.backgroundImage = `url(${thumbnails[index].getAttribute(&#8216;data-bg&#8217;)})`; }; \/\/ Left arrow click event document.getElementById(&#8216;left&#8217;).onclick = () => { currentIndex = (currentIndex &#8211; 1 + thumbnails.length) % thumbnails.length; updateBackground(currentIndex); }; \/\/ Right arrow click event document.getElementById(&#8216;right&#8217;).onclick = () &hellip;<\/p>\n","protected":false},"author":2,"featured_media":82430,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-82429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/82429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=82429"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/82429\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/82430"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=82429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=82429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=82429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}