对于下面的代码,我必须使用4个函数来显示4个输入字段的值。
FD_CLOEXEC

有没有办法只用一个函数来做同样的工作?
答案 0 :(得分:3)
尝试这个
function myFunction1(val) {
var x = val;
document.getElementById("demo").innerHTML = x;
}
Name: <input type="text" id="name1" value="" onBlur="myFunction1(this.value)"><br>
Age: <input type="number" id="age1" value="" onBlur="myFunction1(this.value)"><br>
Job: <input type="text" id="job1" value="" onBlur="myFunction1(this.value)"> <br>
Tel: <input type="text" id="tel1" value="" onBlur="myFunction1(this.value)"> <br>
<p>Type then click outside to display the value of the input field.</p>
Your input:
<p id="demo"></p>
答案 1 :(得分:1)
你可以这样做:
'../_mocks_/utilities'
答案 2 :(得分:1)
<!DOCTYPE html>
<html>
<body>
Name: <input type="text" id="name1" value="" onBlur="myFunction(this)"><br>
Age: <input type="number" id="age1" value="" onBlur="myFunction(this)"><br>
Job: <input type="text" id="job1" value="" onBlur="myFunction(this)"> <br>
Tel: <input type="text" id="tel1" value="" onBlur="myFunction(this)"> <br>
<p>Type then click outside to display the value of the input field.</p>
Your input:
<p id="demo"></p>
<script>
function myFunction(arg) {
var id = arg.getAttribute('id');
var x = document.getElementById(id).value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
答案 3 :(得分:0)
merge into table_a a
using table_b b
on (a.id = b.id)
when matched then
update set a.salary = b.salary
when not matched then
insert (id, salary) values (b.id, b.salary);
&#13;
function myFunction(val) {
document.getElementById("demo").innerHTML = val;
}
&#13;
答案 4 :(得分:0)
将参数传递给函数。
<body>
Name: <input type="text" id="name1" value="" onBlur="myFunction1(this.value)"><br>
Age: <input type="number" id="age1" value="" onBlur="myFunction1(this.value)"><br>
<p>Type then click outside to display the value of the input field.</p>
Your input:
<p id="demo"></p>
<script>
function myFunction1(val) {
document.getElementById("demo").innerHTML = val;
}
</script>
但我认为你需要的就是这个。
Name: <input type="text" id="name1" value="" onBlur="myFunction1(this.value)"><br>
Age: <input type="number" id="age1" value="" onBlur="myFunction2(this.value)"><br>
<p>Type then click outside to display the value of the input field.</p>
Name Your input:
<p id="demo"></p>
Age Your input:
<p id="demo1"></p>
<script>
function myFunction1(val) {
document.getElementById("demo").innerHTML = val;
}
function myFunction2(val) {
document.getElementById("demo1").innerHTML = val;
}
</script>