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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

將文本字段輸入除以設(shè)置的數(shù)字,顯示結(jié)果

將文本字段輸入除以設(shè)置的數(shù)字,顯示結(jié)果

PHP
慕哥6287543 2023-11-06 15:35:19
我有一個(gè)文本字段,需要除以某些輸入。我嘗試使用下面的代碼,但遇到了問題。它不考慮小數(shù)點(diǎn),如果使用小數(shù)點(diǎn),將返回 0。<input id="number" type="text"> ÷ 3.181818<br />Your output is: <div id="output"></div><script type="text/javascript">//obtain reference to number html elementvar number = document.getElementById('number');//obtain reference to output html elementvar output = document.getElementById('output');//what you want to divide tovar division = '3.181818'; // can't be 0, or the world will explode//add an eventlistener to the change event on the number elementnumber.addEventListener('keyup', function(e) {  //get the value from the input  var val = parseFloat(number.value);  //check if it is a nan  if(!isNaN(val)) {     //round it to 0 digits     output.innerHTML = (val / division).toFixed(0) + "";  } else {     output.innerHTML = 'that\'s not a number!';  }});</script>因此,例如,如果有人在文本框中輸入他們的敏感度為1.2,那么就會(huì)這樣做1.2 / 3.181818 = 0.377142878690.37714287869成為他們新的敏感性。
查看完整描述

1 回答

?
翻過高山走不出你

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個(gè)贊

刪除toFixed并設(shè)置div為浮動(dòng)3.181818:


//obtain reference to number html element

var number = document.getElementById('number');


//obtain reference to output html element

var output = document.getElementById('output');


//what you want to divide to

var division = 3.181818; // can't be 0, or the world will explode


//add an eventlistener to the change event on the number element

number.addEventListener('keyup', function(e) {


  //get the value from the input

  var val = parseFloat(number.value);


  //check if it is a nan

  if (!isNaN(val)) {


    output.innerHTML = val / division;

  } else {

    output.innerHTML = 'that\'s not a number!';

  }

});

<input id="number" type="text"> ÷ 3.181818<br /> Your output is:

<div id="output"></div>


查看完整回答
反對(duì) 回復(fù) 2023-11-06
  • 1 回答
  • 0 關(guān)注
  • 134 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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