前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >Jquery插件知识之Jquery.cookie实现页面传值

Jquery插件知识之Jquery.cookie实现页面传值

作者头像
用户9184480
发布2024-12-17 16:43:14
发布2024-12-17 16:43:14
5700
代码可运行
举报
文章被收录于专栏:云计算linux
运行总次数:0
代码可运行
代码语言:javascript
代码运行次数:0
复制
<span >//login.html页面</span>

代码语言:javascript
代码运行次数:0
复制
<!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页面

代码语言:javascript
代码运行次数:0
复制
<!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>
代码语言:javascript
代码运行次数:0
复制
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-04-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档