Help Mode Demo

by michananya

HTML

<link rel="stylesheet" href="styles.css" />

  <button id="toggle-help">Toggle Help Mode</button>

  <div class="ui-element" data-help="This is a helpful tooltip for Button A">Button A</div>
  <div class="ui-element" data-help="Information about Button B">Button B</div>
  <div class="ui-element">No Help Here</div>
  <div class="ui-element" data-help="This section updates user settings.">Settings</div>

CSS

body {
  font-family: Arial, sans-serif;
  padding: 20px;
}

#toggle-help {
  margin-bottom: 20px;
}

.ui-element {
  padding: 10px 20px;
  margin: 10px 0;
  background: #eee;
  border: 1px solid #ccc;
  display: inline-block;
  position: relative;
  cursor: pointer;
}

.ui-element[data-help]:hover::after {
  content: attr(data-help);
  position: absolute;
  top: 100%;
  left: 0;
  background: #333;
  color: white;
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin-top: 5px;
  font-size: 12px;
  z-index: 100;
}

.blink-highlight {
  animation: blink-bg 2s ease-in-out;
}

@keyframes blink-bg {
  0%, 100% {
    background-color: rgba(255, 192, 203, 0.5);
  }
  50% {
    background-color: rgba(255, 192, 203, 0.9);
  }
}

JavaScript

let helpMode = false;

document.getElementById("toggle-help").addEventListener("click", () => {
  helpMode = !helpMode;
  const elements = document.querySelectorAll("[data-help]");
  elements.forEach(el => {
    if (helpMode) {
      el.classList.add("blink-highlight");
      setTimeout(() => el.classList.remove("blink-highlight"), 2000);
    }
  });
});