选择项目的下一个兄弟只需单击 [英] Selecting the next sibling of the item just clicked

查看:78
本文介绍了选择项目的下一个兄弟只需单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 ul ,其中包含图片。这些图像是从twitter获取的配置文件图像,并动态附加到 ul 。一旦用户点击任何图像,我还需要将图像的节点缓存在它旁边(下一个兄弟)。我尝试使用 next()选择器,如下所示,但在控制台中记录的是我不明白的消息。以下是代码:

I have a ul which contains images. These images are profile images fetched from twitter and appended into the ul dynamically. Once the user clicks on any of the images, I need to also cache the node of the image right next to it (the next sibling). I tried using the next() selector like below, but what gets logged in the console is a message I do not understand. Here is the code:

$("ul#container").on("click", "img", function(){
  var nextImage = $(this).next();
  console.log(nextImage);
}

以下是在控制台中记录的内容:

Here is what gets logged in the console:


[prevObject:p.fn .p.init [1],context :, selector:。next()]

[prevObject: p.fn.p.init[1], context: , selector: ".next ()"]

你能帮我理解一下我做错了?感谢您阅读!

Could you please help me understand what I am doing wrong? Thanks for reading!

推荐答案

没错。

这就是Chrome现在记录jQuery对象的方式。

That is how Chrome now logs jQuery objects.

现在去玩吧!

这篇关于选择项目的下一个兄弟只需单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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