<html>
<head>
<title>
</title>
<script type="text/javascript">
function createCookie(newCookie)
{
var expDate = new Date()
expDate.setYear(expDate.getYear() + 1);
var cookieVal = document.getElementById(newCookie).value;
document.cookie = newCookie + " = " + cookieVal + "<br />";
}
</script>
</head>
<body>
Please enter your email<input type="text" id="email" onblur="createCookie('email');" /><br />
Please enter your address<input type="text" id="address" onblur="createCookie('address');" /><br />
Please enter your phone number<input type="text" id="phone" onblur="createCookie('phone');" /><br />
<script type="text/javascript">
document.write("EveryCookie: " + document.cookie);
</script>
</body>
</html>
我的问题是,有没有一种方法可以在我的 cookie 有值时隐藏 HTML 输入,以便只看到 cookie,如果 cookie 没有值,则再次显示 HTML 输入。