11.21 javascript関数
1044 ワード
<script type="text/javascript">
function elementValue(ele){
return ele.value;
}
function elementInnerHTML(ele){
return ele.innerHTML;
}
function concatAll(nodes,content){
var result='';
for(var i=0;i<nodes.length;i++){
result=result+content(nodes[i]);
}
return result;
}
function fill(){
var nodes=document.getElementById("input");
var result=concatAll(nodes,elementValue);
var out=document.getElementById("out");
out.innerHTML=result;
}
</script>
<body>
<button onclick="fill()"> </button>
<input type="text">
<input type="text">
<input type="text">
<div id="out">
</body>