TGViewer
Html and Css & Jsآموزش Html and Css & Jsآموزش @htmlcss_channels · 22.9K subscribers
Post #266 9.85K
با کلیک کردن، رنگ پس زمینه را تغییر دهید

این کد صفحه ای ایجاد می کند که با کلیک کردن یا بارگذاری صفحه، رنگ پس زمینه را تغییر می دهد. هر کلیک یک رنگ تصادفی جدید در قالب HEX ایجاد می کند:

body {
transition: background-color 0.5s ease;
margin: 0;
height: 100vh;
}


function changeBackground() {
const randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
document.body.style.backgroundColor = randomColor;
}
document.body.addEventListener('click', changeBackground);


🆔 @htmlcss_channels
  • 👍 36
  • ❤ 10
  • 👎 4
  • 🔥 1
More from @htmlcss_channels
  1. Oct 10, 2026🎰 گردونه رو بچرخون، جایزه ببر! 👀 فقط یه چرخش تا جایزه‌ت فاصله داری. 🔗https://quera.org/…
  2. Oct 10, 2026غول فناوری و هوش مصنوعی یک سرور قدرتمند برای نسل جدید پردازش‌های هوش مصنوعی و زیرساخت‌های…
  3. Oct 3, 2026HTML Shortcuts You Must Know 💎 @Htmlcss_channels | #HTML #css #JavaScript
  4. Oct 2, 2026سایت StringTune یه مجموعه از کامپوننت های آماده برای ساخت تجربه‌های تعاملی و انیمیشن‌های م…
  5. Oct 1, 2026📊 نمودارهای آماده و انیمیشن‌دار برای React با EvilCharts نمودارهایی مثل Line، Bar، Pie و…
  6. Sep 30, 2026If you have a website, incorporating an AI agent (or several) can be really helpful. And i…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →