javascript - parent() 的问题 (jQuery)

标签 javascript jquery css parent-child parent

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") 时没有任何变化?

最佳答案

我认为问题可能在于使用 children()多人使用parent() .

$(this).parent().parent()没有直达<img> children ……有吗?

尝试替换 children()通过 find() ;)

关于javascript - parent() 的问题 (jQuery),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3774921/

相关文章:

javascript - 在页面刷新之前,navigator.serviceWorker.controller 为 null

jQuery AJAX 请求 302 重定向 - 哪些回调可用?

jquery - 使用 jQuery DataTables 添加按钮到工具栏

jquery - 创建自定义的响应式网站导航栏/菜单

html - 列表图表 HTML CSS

javascript - 水平和垂直独占单选按钮

javascript - 为什么我在尝试使用 ajax 调用返回的 Promise 时没有获取任何数据

html - Cordova iOS模拟器只显示320px(我的内容是640px)

javascript - 当用户放大或缩小时防止背景图像缩放

javascript - jquery 数组不相等