我在html和jquery中有一个表单,我想设置cookie,我该怎么做?
{
<script>
$(document).ready(function() {
$('#back').fadeIn(1000);
});
$(document).ready(function() {
$('#close-btn').click(function(){
$('#popup').fadeOut("fast");
});
});
</script>
<html>
<body>
<div id="popup">
<div id="back">
<div id="right">
<div style="width:18px; height:19px;">
<img src="img/Close.png" width="18" style="cursor:pointer;display:block; margin- left:350px;margin-top:-2px;" onclick="document.getElementById('back').style.display='none';"/>
</div>
<div id="login-box">
<form id="login" name="welcome" action="#" method="post">
<div id="c" >
<span style="font:B Mitra; font-size:24px; font-weight:bold; color:#000;padding- left:270px;position:relative;top:-40px;"> ایمیل</spam>
<input name="username" onfocus="if (this.value = 'آدرس ایمیل') { this.value=''; }" onblur="if (this.value == '') { this.value='آدرس ایمیل'; }" style="position:absolute; margin:-30px 0 0 60px; width:215px; height:25px; text-align:right; background:#ffffff; border:2px solid #0CF;border-radius:10px; color:#000; font:11px tahoma; left: -15px; top: 29px; border-radius:5px;" type="text" value="آدرس ایمیل "></div>
<div style="margin-top:35px;margin-left:120px;">
<input value="ارسال" name="submit" type="submit" style="background-color:#fcaf17;border-radius:5 px; border:none; width:109px;height:35px; font-family:tahoma; color:#FFF; font-size:18px;
font-weight:bold; ">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
}
答案 0 :(得分:0)
您可以使用jQuery Cookie plugin轻松设置,阅读和删除Cookie。
// Set a cookie
$.cookie('foo', 'bar');
// Read a cookie
$.cookie('foo'); // returns bar
// Delete a cookie
$.removeCookie('foo');