打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

用户:Xp00000000/Sandbox:修订间差异

来自Rizline中文维基
Xp00000000留言 | 贡献
无编辑摘要
Xp00000000留言 | 贡献
无编辑摘要
第69行: 第69行:


<html>
<html>
<!-- 状态切换按钮 -->
<div id="state-switcher" data-states='["EZ 1", "HD 6", "IN 9"]' onclick="switchState(this)">
  EZ 1
</div>
<!-- 其他输出区域 -->
<div id="output-area-1"></div>
<div id="output-area-2"></div>
<script>
<script>
function switchState(element) {
function cycleTextData(element) {
  // 切换状态
   const states = JSON.parse(element.dataset.states || '["A", "B", "C"]');
   const states = JSON.parse(element.dataset.states);
   const currentIndex = parseInt(element.dataset.current || 0);
   const nextIndex = (parseInt(element.dataset.current || 0) + 1 % states.length;
  const nextIndex = (currentIndex + 1) % states.length;
   const newState = states[nextIndex];
    
   element.textContent = newState;
   element.textContent = states[nextIndex];
   element.dataset.current = nextIndex;
   element.dataset.current = nextIndex;
 
 
   // 检测其他区域并更新内容
  // 检测当前文本(方法1)
   updateOutputs(newState);
  console.log("当前文本(方法1):", element.textContent);
 
   // 检测当前文本(方法2)
  const currentText = states[nextIndex];
   console.log("当前文本(方法2):", currentText);
}
}


function updateOutputs(state) {
// 示例:通过按钮检测当前文本
   const output1 = document.getElementById('output-area-1');
function checkCurrentText() {
   const output2 = document.getElementById('output-area-2');
   const element = document.querySelector('div[data-states]');
 
   alert("当前显示的文本是: " + element.textContent);
  // 根据状态检测并输出不同内容
  if (state === "EZ 1") {
    output1.textContent = "检测到状态: EZ 1 → 输出A";
    output2.innerHTML = "<span style='color:green'>✓ 条件满足</span>";
  }
  else if (state === "HD 6") {
    output1.textContent = "检测到状态: HD 6 → 输出B";
    output2.innerHTML = "<span style='color:blue'>⚠️ 注意阈值</span>";
  }
  else if (state === "IN 9") {
    output1.textContent = "检测到状态: IN 9 → 输出C";
    output2.innerHTML = "<span style='color:red'>✗ 超限</span>";
  }
}
}
</script>
</script>
<div onclick="cycleTextData(this)" data-states='["EZ 1", "HD 6", "IN 9"]'
    data-current="0" style="cursor:pointer;">
  EZ 1
</div>
<button onclick="checkCurrentText()">检测当前文本</button>
</html>
</html>

2025年7月5日 (六) 10:02的版本

EZ 1
4:3
abc

EZ 1
4:3
a_ccc_1234.png


EZ 1