我有一个输入类型编号,并且将同一输入的不同值存储在不同的变量中。示例变量1的input.value为5,变量number2的input.value为3,来自同一输入。 这是我到目前为止尝试过的方法,我知道这是不对的,因为会给出空字符串,但这就是我寻求帮助的原因。
* {
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
}
.container-fluid .wrapper {
display: flex;
position: relative;
}
.container-fluid .wrapper .sidebar {
position: fixed;
width: 200px;
height: 100%;
background: #4b4276;
padding: 30px 0;
}
<div class="container-fluid">
<div class="wrapper">
<div class="sidebar">
<h2>Paperpay</h2>
<ul>
<li><a href="#"><i class="fas fa-file-invoice"></i>Statements</a></li>
<li><a href="#"><i class="fas fa-users"></i>Profile</a></li>
<li><a href="#"><i class="far fa-newspaper"></i>Newspapers</a></li>
</ul>
</div>
<div class="main_content">
<div class="header">Welcome to Paper Pay</div>
<div class="info">
welcom to info
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
输入将始终为''
let input = document.querySelector('#input');
let output = document.querySelector('#output');
let number1 = input.value;
console.log('this is number1' + number1);
input.value = '' ; // <-- You're setting the value of #input here
if( number1) {
let number2 = document.querySelector('#input');
number2 = number2.value;
console.log('this is number2' + number2);
}
output.innerHTML = input.value ;