<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>JavaScript - Форум программистов и сисадминов Киберфорум</title>
		<link>https://www.cyberforum.ru/</link>
		<description>Форум программистов JavaScript. Обсуждение вопросов использования API различных сайтов и сервисов в JavaScript.</description>
		<language>ru</language>
		<lastBuildDate>Sun, 04 Oct 2026 10:13:23 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>https://www.cyberforum.ru//cyberstatic.net/images/misc/rss.jpg</url>
			<title>JavaScript - Форум программистов и сисадминов Киберфорум</title>
			<link>https://www.cyberforum.ru/</link>
		</image>
		<item>
			<title>Плавная смена картинок по нажатию кнопки - JavaScript для начинающих</title>
			<link>https://www.cyberforum.ru/javascript-beginners/thread3226006.html</link>
			<pubDate>Wed, 30 Sep 2026 14:13:01 GMT</pubDate>
			<description>Добрый день. Столкнулся с проблемой.  
Я вывожу картинку на экран и две кнопки. При нажатии любой...</description>
			<content:encoded><![CDATA[<div>Добрый день. Столкнулся с проблемой. <br />
Я вывожу картинку на экран и две кнопки. При нажатии любой кнопки меняю эту картинку. <br />
Выбросил всё лишнее, остался только требуемый функционал. По нажатию любой кнопки картинка меняется, все отлично. <br />
Но я хочу менять картинки плавно. Добавил класс visible и opacity+transition. При первом нажатии картика быстро меняется и плавно гаснет, пустой экран.<br />
При втором нажатии появляется плавно новая картинка, это хорошо. При следующем нажатии опять резкая смена и плавное затухание картики.<br />
Тоесть работает через раз.<br />
<div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">&nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=&quot;content2&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;img id=&quot;fram&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button id=&quot;button1&quot; class=&quot;item&quot; onclick=&quot;Answer(1)&quot;&gt;Кнопка1&lt;/button&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button id=&quot;button2&quot; class=&quot;item&quot; onclick=&quot;Answer(2)&quot;&gt;Кнопка2&lt;/button&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;</code><hr />
</div><div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">#content2&nbsp; { <br />
&nbsp; &nbsp; &nbsp;  width: 100%; <br />
&nbsp; &nbsp; &nbsp;  height: 82%; <br />
&nbsp; &nbsp; &nbsp;  text-align: center; <br />
}<br />
#fram { <br />
&nbsp; &nbsp; &nbsp; &nbsp; width: 90%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; height: 80%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; object-fit: contain;<br />
&nbsp; &nbsp; &nbsp; &nbsp; opacity: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; transition: opacity 1s ease-in-out;<br />
}<br />
#fram.visible { <br />
&nbsp; &nbsp; &nbsp; &nbsp; opacity: 1;<br />
}</code><hr />
</div><div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">let step=1;<br />
var tickets = &#91; &#91;&quot;Image&quot;&#93;,&nbsp; &#91;&quot;img/Vasnetsov-vitaz-crossroad.jpg&quot;&#93;,&nbsp; &#91;&quot;img/Vasnetsov-alyonushka.jpg&quot;&#93;,&nbsp; &#91;&quot;img/Vasnetsov-warriors-pocalypse.jpg&quot;&#93;,&nbsp; &#91;&quot;img/Vasnetsov-bogatyrs.jpg&quot;&#93;,&nbsp; &#91;&quot;img/Vasnetsov-spyashaya-carevna.jpg&quot;&#93; &#93;;<br />
<br />
document.addEventListener('DOMContentLoaded', function() { // Код, который должен выполниться после полной загрузки DOM (HTML)<br />
&nbsp; console.log('DOM is fully loaded and parsed.'); //DOM полностью загружен и разобран<br />
&nbsp; Main(); // Теперь можно безопасно работать с элементами страницы, исключается ошибка «Cannot read properties of null (reading 'style')»<br />
});<br />
<br />
function Main() { <br />
&nbsp; &nbsp; &nbsp; &nbsp; Answ(); <br />
}<br />
<br />
function Answ() { //выводим картинку, кнопки<br />
&nbsp; &nbsp; &nbsp; &nbsp; const fr = document.getElementById(&quot;fram&quot;); fr.src=tickets&#91;step&#93;;&nbsp; fr.classList.toggle('visible');<br />
}<br />
<br />
function Answer(d) { //Принимаем ответ<br />
&nbsp; &nbsp; &nbsp; &nbsp; step++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( step&gt;5 ) { step=1; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; Answ();<br />
}</code><hr />
</div>Ну и вопрос, как плавно менять картинки? Вроде как это слайдер, но в рассматриваемых примерах везде несколько IMG, а у меня в одном IMG все процессы. Лучше конечно чистый CSS + JS.<br />
<br />
<font size="1"><font color="grey"><i>Добавлено через 4 часа 10 минут</i></font></font><br />
Пока никто не откликнулся. Копаю сам. Переделал функционал.<br />
<div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">#img8 { <br />
&nbsp; &nbsp; &nbsp; &nbsp; width: 90%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; height: 80%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; object-fit: contain;<br />
}</code><hr />
</div><div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">function Answ() { //выводим картинку<br />
&nbsp; &nbsp; &nbsp; &nbsp; var fr = document.getElementById(&quot;img8&quot;); fr.src=tickets&#91;step&#93;; fr.style.opacity = 1; <br />
&nbsp; &nbsp; &nbsp; &nbsp; FadeOn();<br />
}<br />
<br />
function Answer(d) { //Принимаем нажатие кнопки<br />
&nbsp; &nbsp; &nbsp; &nbsp; step++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( step&gt;5 ) { step=1; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; Answ();<br />
}<br />
<br />
function FadeOn() { //элемент становится прозрачным, невидимым<br />
&nbsp; &nbsp; &nbsp;  var img88 = document.images.img8;<br />
&nbsp; &nbsp; &nbsp;  img88.style.opacity -= 0.05;<br />
&nbsp; &nbsp; &nbsp;  if (img88.style.opacity&gt;0)&nbsp; { setTimeout(() =&gt; { FadeOn(); }, 100); } <br />
}</code><hr />
</div>Картинка появляется резко в полный рост и после нажатия кнопки плавно растворяется. <br />
Каждая картинка, без всяких пропусков. Теперь надо переделать наоборот. Чтобы появлялась плавно.</div>

]]></content:encoded>
			<category domain="https://www.cyberforum.ru/javascript-beginners/">JavaScript для начинающих</category>
			<dc:creator>soft42</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/javascript-beginners/thread3226006.html</guid>
		</item>
		<item>
			<title>Работа с локально подключенным js файлом - JavaScript для начинающих</title>
			<link>https://www.cyberforum.ru/javascript-beginners/thread3225967.html</link>
			<pubDate>Mon, 28 Sep 2026 05:18:44 GMT</pubDate>
			<description><![CDATA[Хелоу дие ситезен оф форум! Доброго утра. 
Имею файл "f3.js" window.m='mmm'; подключаю к основному...]]></description>
			<content:encoded><![CDATA[<div>Хелоу дие ситезен оф форум! Доброго утра.<br />
Имею файл &quot;f3.js&quot; <div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">window.m='mmm';</code><hr />
</div> подключаю к основному файлу так <div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">&lt;script src=&quot;f3.js&quot; defer&gt;&lt;/script&gt;</code><hr />
</div>  и вызываю в основном файле: <br />
<div class="printablecode">
	<div class="smallfont">:</div>
	<hr /><code dir="ltr">console.log(window.m);</code><hr />
</div>дает <b>undefined</b>. Как исправить? Заранее спасибо.</div>

]]></content:encoded>
			<category domain="https://www.cyberforum.ru/javascript-beginners/">JavaScript для начинающих</category>
			<dc:creator>russiannick</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/javascript-beginners/thread3225967.html</guid>
		</item>
	</channel>
</rss>
