Jquery插件知识之Jquery.cookie实现页面传值
【摘要】
<span style="color:#ff0000;">//login.html页面</span>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml...
<span style="color:#ff0000;">//login.html页面</span>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>无标题文档</title>
-
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
-
<script src="jquery.cookie.js" type="text/javascript"></script>
-
<script>
-
$(document).ready(
-
function(){
-
$("#btnOk").click(
-
function(){
-
//存放刚才的zhang.laoshi信息;
-
//$.cookie('user',$("#user").val()); //user:存放信息key;value
-
//alert($("#meiniu").attr("src"));
-
$.cookie('src',$("#meiniu").attr("src"));
-
}
-
);
-
}
-
);
-
</script>
-
</head>
-
-
<body>
-
<form id="form1" name="form1" method="post" action="success.html" ><!--action提交到某个页面;get:提交方式?user='zhang' and pwd='123'-->
-
<table width="800" border="0" align="center">
-
<tr>
-
<td width="65">用户:</td>
-
<td width="613"><input type="text" name="user" id="user" /></td>
-
<td width="108"> </td>
-
</tr>
-
<tr>
-
<td>图片</td>
-
<td><img src="meiniu.jpg" width="118" height="79" id="meiniu" /></td>
-
<td> </td>
-
</tr>
-
<tr>
-
<td><input type="submit" name="button" id="btnOk" value="提交" /></td>
-
<td><input type="reset" name="button2" id="button2" value="重置" /></td>
-
<td> </td>
-
</tr>
-
</table>
-
</form>
-
</body>
-
</html>
-
-
//2.提交之后的success.html页面
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>无标题文档</title>
-
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
-
<script src="jquery.cookie.js" type="text/javascript"></script>
-
<script>
-
$(document).ready(
-
function(){
-
//显示到div里面;
-
//$("#content").html($.cookie('user')); //html:相当于div的innerHTML
-
var s=$.cookie('src');
-
$("#meiniu").prop("src",s);
-
}
-
);
-
-
</script>
-
</head>
-
-
<body>
-
-
<div id="content" style="border:1px solid #f00; width:600px; height:300px;">
-
<img id="meiniu" src="" width="118" height="79"/>
-
</div>
-
</body>
-
</html>
文章来源: aaaedu.blog.csdn.net,作者:tea_year,版权归原作者所有,如需转载,请联系作者。
原文链接:aaaedu.blog.csdn.net/article/details/51543207
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)