修改页面值获取数据存到localStorage在赋值

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<meta charset="utf-8" />

<title>excel demo</title>

<script src="" target="_blank">https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>

<style>

</style>

<script type="text/javascript">

let a = {}

let b = {}

let c = {}

let d = {}

let e = {}

let f = {}

function box1Function() {

const inputBox = document.querySelectorAll('.box1')[0]

// 获取input输入框中的值

let inputVal = inputBox.value;

if (inputVal) {

a = inputVal;

// console.log(a);

// 把值存到localStorage

window.localStorage.setItem('a', JSON.stringify(a))

// var b = JSON.parse(window.localStorage.getItem('ax'))

// console.log(b);

} else {

alert('请在input输入框中填点东西');

}

}

// 获取localStorage里面的值

var a1 = JSON.parse(window.localStorage.getItem('a'))

if (a1 == null) {

document.write('<textarea οnchange="box1Function()" class="input-box box1" >4、xxxxxxxx。</textarea>')

} else {

document.write('<textarea οnchange="box1Function()" class="input-box box1" >' + a1 + '</textarea>')

}

$("#ltx_2").append($('.box1'));

function box2Function() {

const inputBox = document.querySelectorAll('.box2')[0]

// 获取input输入框中的值

let inputVal = inputBox.value;

if (inputVal) {

b = inputVal;

// console.log(b);

window.localStorage.setItem('b', JSON.stringify(b))

} else {

alert('请在input输入框中填点东西');

}

}

var b1 = JSON.parse(window.localStorage.getItem('b'))

if (b1 == null) {

document.write('<textarea οnchange="box2Function()" class="input-box box2" >5、xxxxx</textarea>')

} else {

document.write('<textarea οnchange="box2Function()" class="input-box box2" >' + b1 + '</textarea>')

}

$("#ltx_2").append($('.box2'));

function box5Function() {

const inputBox = document.querySelectorAll('.box5')[0]

// 获取input输入框中的值

let inputVal = inputBox.value;

if (inputVal) {

e = inputVal;

// console.log(b);

window.localStorage.setItem('e', JSON.stringify(e))

} else {

alert('请在input输入框中填点东西');

}

}

var e1 = JSON.parse(window.localStorage.getItem('e'))

if (e1 == null) {

document.write('<textarea οnchange="box5Function()" class="input-box box5" >6、xxxxx</textarea>')

} else {

document.write('<textarea οnchange="box2Function()" class="input-box box5" >' + e1 + '</textarea>')

}

$("#ltx_2").append($('.box5'));

function box3Function() {

const inputBox = document.querySelectorAll('.box3')[0]

// 获取input输入框中的值

let inputVal = inputBox.value;

if (inputVal) {

c = inputVal;

// console.log(c);

window.localStorage.setItem('c', JSON.stringify(c))

} else {

alert('请在input输入框中填点东西');

}

}

var c1 = JSON.parse(window.localStorage.getItem('c'))

if (c1 == null) {

document.write('<textarea οnchange="box3Function()" class="input-box box3" >1、xxxx</textarea>')

} else {

document.write('<textarea οnchange="box3Function()" class="input-box box3" >' + c1 + '</textarea>')

}

$("#ltx_1").append($('.box3'));

function box4Function() {

const inputBox = document.querySelectorAll('.box4')[0]

// 获取input输入框中的值

let inputVal = inputBox.value;

if (inputVal) {

d = inputVal;

// console.log(a);

window.localStorage.setItem('d', JSON.stringify(d))

} else {

alert('请在input输入框中填点东西');

}

}

var d1 = JSON.parse(window.localStorage.getItem('d'))

// console.log(d1);

if (d1 == null) {

document.write('<textarea οnchange="box4Function()" class="input-box box4" >2、xxxxx</textarea>')

} else {

document.write('<textarea οnchange="box4Function()" class="input-box box4" >' + d1 + '</textarea>')

}

$("#ltx_1").append($('.box4'));

function box6Function() {

const inputBox = document.querySelectorAll('.box6')[0]

// 获取input输入框中的值

let inputVal = inputBox.value;

if (inputVal) {

f = inputVal;

window.localStorage.setItem('f', JSON.stringify(f))

} else {

alert('请在input输入框中填点东西');

}

}

var f1 = JSON.parse(window.localStorage.getItem('f'))

if (f1 == null) {

document.write('<textarea οnchange="box6Function()" class="input-box box6" >3、xxxxx</textarea>')

} else {

document.write('<textarea οnchange="box6Function()" class="input-box box6" >' + f1 + '</textarea>')

}

$("#ltx_1").append($('.box6'));

box2Function()

</script>

</head>

<body>

</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值