第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用切換滑塊js

如何使用切換滑塊js

翻閱古今 2021-06-28 20:09:03
我正在嘗試使用 html 中的滑塊切換值,這是我所做的: html 文件:    <!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"><script scr="./scripts.js" type="text/javascript"></script></head><body style="font-family: Calibri; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 100; line-height: 26.4px;"><div id="myDIV">Hello</div>        <h2> Testing switch:                <label class="switch">                  <input id="status" type="checkbox" checked>                  <span class="slider round" ></span>              </h2></body>這里是scripts.js我使用的代碼:function myFunction() {  var x = document.getElementById("myDIV");  var isChecked = document.getElementById("status");  if (isChecked.checked ==true) {    x.innerHTML = "Swapped text!";  } else {    x.innerHTML = "Hello";  }}我不明白我錯過了什么,但移動幻燈片不會改變文本!知道我該如何解決這個問題嗎?提前致謝 !
查看完整描述

2 回答

?
呼喚遠方

TA貢獻1856條經(jīng)驗 獲得超11個贊

您需要以某種方式觸發(fā)您的功能。它不會自動運行。下面的示例通過myFunction在復選框使用onChange屬性更改值時運行來修復該問題。


function myFunction() {

  var x = document.getElementById("myDIV");

  var isChecked = document.getElementById("status");

  if (isChecked.checked == true) {

    x.innerHTML = "Swapped text!";

  } else {

    x.innerHTML = "Hello";

  }

}

<!DOCTYPE html>

<html>


<head>

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

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

  <script scr="./scripts.js" type="text/javascript"></script>

</head>


<body style="font-family: Calibri; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 100; line-height: 26.4px;">

  <div id="myDIV">Hello</div>

  <h2> Testing switch:

    <label class="switch">

    <input id="status" type="checkbox" checked onChange="myFunction(this)">

    <span class="slider round" ></span>

  </h2>

</body>


查看完整回答
反對 回復 2021-07-01
  • 2 回答
  • 0 關(guān)注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號