Jquery插件知识之Jquery.cookie实现页面传值
2016-05-31 09:37
489 查看
<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>
相关文章推荐
- jQuery基础知识点总结(必看)
- 如何使用jquery刷新当前页面
- jquery 无限极下拉菜单的简单实例(精简浓缩版)
- 使用jQuery实现input的灰色提示信息
- Jquery toggleClass的使用
- jQuery 阻止表单重复提交
- JQuery中的.attr()与.removeAttr()
- jQuery基础知识点(上)
- jquery ajax监听 then when done
- 关于在实际开发中遇到的js或者是jQuery方法
- jQuery百度选项卡片切换
- jquery ajax POST 例子详解
- js/jquery如何这样调用php?
- jquery mobile在chrome浏览器中一直处于在家在状态(圆圈一直在转)的解决方案
- JQUERY知识总结
- 使用jquery获取父元素或父节点的方法
- .attr()与.removeAttr()
- JQuery中的特殊选择器--this
- JQuerySelectors
- JQiery选择器中的表单元素