如何打开一个新页面,显示与使用jquery单击时相同的图像 [英] How to open a new page with the same image showing as you clicked on using jquery

查看:93
本文介绍了如何打开一个新页面,显示与使用jquery单击时相同的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对javascript比较陌生,我正在寻找解释此问题的最佳方法.希望任何人都可以给我建议

I am relatively new to javascript and I'm looking for the best possible way to explain this problem. Hope anyone can give me advice on this

我有这个:

<div class="col-md-4">
        <a href="stuffedd.html"><img src=""></a>
        <a href="stuffedd.html"><img src=""></a>
        <a href="stuffedd.html"><img src=""></a>
</div>

在img上单击时,它将重定向到stuffedd.html页面.但是,其中包含2列图像.垂直缩略图列和中间列具有大图像.

When Clicked on img it's redirected to the stuffedd.html page. However this contains 2 columns with images. A vertical thumbnail column and a middle column with large image.

赞:

<div class="middle containerscroll">
    <img src="" id="Mdrie" class="img-responsive ">
    <img src="" id="Mvier" class="img-responsive ">
    <img src="" id="Mvijf" class="img-responsive ">
</div>
div class="col-md-9 hidden-xs hidden-sm">
    <img src="" id="drie" class="img-responsive single">
    <img src="" id="vier" class="img-responsive single">
    <img src="" id="vijf" class="img-responsive single">
</div>

我已经通过Jquery实现了这一目标:

I got this far with Jquery :

$(document).ready(function(){

"use strict";
$( ".single" ).hide();

$( "#Mdrie" ).on('click',function() {     
 $('#drie').toggle();
$(".single").not('#drie').hide();

});

如何打开在第二个div中单击的图像的stuffedd.html(所有具有.single类的图像) 我是否声明一个变量,我将其填写为:

How do I make the stuffedd.html open with the image I clicked on in the second div (all the images with class .single) Do I declare a variable which I fill in as:

$( "var" ).show();

网站是:www.damondebacker.com(如果需要查看).

website is: www.damondebacker.com if you need to see it.

推荐答案

如果我理解这个问题,则第二页需要知道您在上一页中单击了什么,请考虑在URL中添加一些用于标识图像的标识符:

If I understand the question, the second page needs to be aware of what you clicked on the previous page, consider adding some identifier into the URL that identifies the image:

<a href="stuffedd.html#Mdrie"><img src=""></a>

然后第二页上有一个提取点.如果您不想在URL中使用它,则可以设置cookie或使用LocalStorage对象.

Then the second page has a spot to extract it from. If you don't want it in the URL you could set a cookie or use the LocalStorage object.

这篇关于如何打开一个新页面,显示与使用jquery单击时相同的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆