如何使用jQuery设置和取消设置cookie,例如创建一个名为cookie并将test值设置为1?
简单的例子:我想在页面上有一些项目(比如div或table行),我想让用户点击它们来选择它们.这在jQuery中似乎很容易.为了保存用户点击的项目而没有服务器端回发,我认为cookie是一种简单的方法来完成这项工作.
I'm trying to save certain data into cookies, in such a way that if I jump from one page to another, the data entered should be saved and retrieved back on refresh. I have a link:
<div class="esc-policy">
<a href="#">New Link</a>
</div>
Run Code Online (Sandbox Code Playgroud)
before i fire the click event i need to save the entered the following data fields:
<table class="form">
<tr>
<td class="label">
<label>Name*</label>
<input id="nameInput" type="text" maxlength="100"/>
</td>
<td class="label">
<label>Description</label>
<input id="descriptionInput" type="text" maxlength="200" >
</td>
</tr>
</table> …Run Code Online (Sandbox Code Playgroud) 在PHP我会做
if (isset($_COOKIE['user']) && $_COOKIE['user'] == $valueFromDb)
echo 'logged';
Run Code Online (Sandbox Code Playgroud)
但是在javascript中我该怎么检查呢?
谢谢