我编写了截图来从MySQL数据库中获取数据。
我添加了JavaScript代码,点击接受按钮接受,点击拒绝按钮拒绝
我想在用户再次打开页面时将这些选择保留在网页中。
如何实施此功能?
<script>
function clickabtn(){
var el = document.getElementById('btnacc');
if(el.textContent=="Accept"){
el.textContent="Accepted";
}else{
el.textContent="Accept";
}
}
</script>
<script>
function clickdbtn(){
var el = document.getElementById('btnde');
if(el.textContent=="Decline"){
el.textContent="Declined";
}else{
el.textContent="Decline";
}
}
</script>
答案 0 :(得分:0)
嘿,只需将值设置为按钮
<script>
function clickabtn(){
var el = document.getElementById('btnacc');
if(el.value == "Accept"){
el.value = "Accepted";
}else{
el.value = "Accept";
}
}
</script>
<script>
function clickdbtn(){
var el = document.getElementById('btnde');
if(el.value == "Decline"){
el.value = "Declined";
}else{
el.value = "Decline";
}
}
</script>