jquery touchgallery显示图片url

发布于 2024-09-28 17:17:57 字数 609 浏览 5 评论 0原文

如何显示文档中单击的图像的链接?

我在单击图像时向图像添加了一个类,效果很好,但是当我想显示使用 getelementbyid 添加该类的图像时,它找不到它,并且在源代码中它不可见。

请帮我!!

编辑:

上面我写了类,但我拿了id!

我有一个网站,在我的应用程序中显示在 iPhone 上。该网站上有一个画廊,在 xcode 中我使用 getelementbyid('download_fullscreen') 获取图像。因此,当点击图像时,它会全屏显示,但这是由 jquery 和插件 touchgallery 生成的,我可以为单击的图像分配一个 id,但 iphone 上的应用程序无法识别它。当我滑动到下一个图像时,id 将不会移动到下一个图像。这是演示: http://neteye.github.com/touch-gallery.html 当您单击图像时,它将全屏显示,并且 gallerycode 是由 javascript 生成的。如何将当前全屏图像中的 imageurl 打印到我的 iphone 应用程序可以识别的文档中?

how can i display the link of the image wich was clicked in the document?

i've added a class to the image when the image was clicked that works fine but when i want to display the image where the class was added with getelementbyid it doesn't find it and in the source code it is not visible.

please help me!!

EDIT:

above i wrote class but i took the id!

i have an website which is displayed on the iphone in my app. on the site is a gallery and in xcode i get the image with getelementbyid('download_fullscreen'). so when the image is tapped it goes fullscreen but this is generated by jquery with the plugin touchgallery i can assign an id to the clicked image but it is not recognized in the app on the iphone. and when i slide to the next image the id will not move to the next image. here is the demo: http://neteye.github.com/touch-gallery.html when you click on an image it will be fullscreen and the gallerycode is generated by javascript. how can i print the imageurl from the image which is currently in fullscreen to the document that my iphone app can recognize it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷乱花海 2024-10-05 17:17:57

仅当您将 ID 分配给标签而不是 CLASS 时,getElementByID 才会返回对象。

例如。 getElementByID 将在这里工作,因为 ID 是通过标签

分配的,但在这种情况下不行。

getElementByID will return object only if you are assigning ID to tag and not CLASS.

For eg. getElementByID will work here as ID is assigned with tag

<img id="myid" class="clicked" src="your_image_path">

But not in this case.

<img class="clicked" src="your_image_path">

月寒剑心 2024-10-05 17:17:57

我不确定你在问什么。如果您已将类添加到 标记,并且您可以通过 document.getElementById() 或其他方式选择图像元素 (< a href="https://developer.mozilla.org/en/dom/document.getelementsbyclassname" rel="nofollow">getElementsByClassName),可以获取元素的src 属性很容易:

var myImage = document.getElementById('myImage');
var imageUrl = myImage.src;

遗憾的是,这只能为您获得相对路径。希望 URL 是绝对的,否则您需要处理它们。希望这会有所帮助!
查看:“MDC 上的 HTMLImageElement”

I'm not sure what you're asking. If you've added a class to an <img> tag, and you're able to select the image element, via document.getElementById() or otherwise (getElementsByClassName), you can get the element's src attribute easily:

var myImage = document.getElementById('myImage');
var imageUrl = myImage.src;

Regrettably, this only gains you a relative path. Hopefully the URLs are absolute, otherwise you'll need to handle them. Hope this helps a little!
Check out: "HTMLImageElement at MDC"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文