父级()(jQuery)的问题

发布于 2024-09-24 17:30:53 字数 861 浏览 0 评论 0原文

的问题

Parent() jQuery 代码 http://webdev.faressoft.org/wp-content/ plugins/ImageSlideShow/js/slideShow.js

您可以在此处查看结果(图像幻灯片) http://webdev.faressoft.org/?p=208

$(".ImageNum span").click(function() {
var image = parseInt($(this).text());
$(".correntImage", $(this).parent()).removeClass("correntImage");
$(this).addClass("correntImage");
$(this).parent().parent().children("img").css("display","none");
$(this).parent().parent().children("img").slice(image-1,image).css("display","block");
$(this).parent().parent().children(".autoSlideShow").text("false");
});

为什么没有当我点击 $(".ImageNum span") 时发生变化?

problem with parent()

jQuery Code
http://webdev.faressoft.org/wp-content/plugins/ImageSlideShow/js/slideShow.js

You can see the result here (Image Slide Show)
http://webdev.faressoft.org/?p=208

$(".ImageNum span").click(function() {
var image = parseInt($(this).text());
$(".correntImage", $(this).parent()).removeClass("correntImage");
$(this).addClass("correntImage");
$(this).parent().parent().children("img").css("display","none");
$(this).parent().parent().children("img").slice(image-1,image).css("display","block");
$(this).parent().parent().children(".autoSlideShow").text("false");
});

why nothing change when i click on $(".ImageNum span") ?

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

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

发布评论

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

评论(1

神经暖 2024-10-01 17:30:53

我认为问题可能是 children() 的使用多于 parent() 的使用。

$(this).parent().parent() 没有直接的 子项...有吗?

尝试用 find() 替换 children() ;)

I think the problem could be the use of children() more than the use of parent().

$(this).parent().parent() has not direct <img> children... has it ?

Try replacing children() by find() ;)

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