<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<!-- <input type="text" oninput="yz(this)"> -->
<input type="text" name="demo" id="ceshi1">
<input type="text" name="demo" id="ceshi2">
<input type="text" name="demo" id="ceshi3">
<span id="ceshi1-s"></span>
<span id="ceshi2-s"></span>
<span id="ceshi3-s"></span>
<button id="save">点击保存</button>
<script src="jquery-1.8.3.min.js"></script>
<script>
var globalData = {}
$("#save").click(function(){
$("input[name='demo']").each(function(){
globalData[$(this).attr("id")] = $(this).val() || "";
});
for(v in globalData){
$("#"+v+"-s").text(globalData[v])
}
console.log(globalData)
})
</script>
</body>
</html>