在 Owl-carousal 中找到我正在点击的元素的索引
Find index of the element i am clicking on in Owl-carousal
这是我上面的 html,我正在尝试获取我点击的视频的索引,我还需要获取 "owl-video" 锚标记的 href。请参阅下面我尝试过的代码。
- To find the a"href" i tried this, which doesn't seem to work.
var target = $(this).closest('.article-video').index('.article-video').find('a').attr('href');
- this is the code i tried to get the index.
$('.article-video').click(function(){
var target = $(this).closest('.article-video').index('.article-video');
console.log(target);
});
我是 Jquery 的初学者,如有错误,敬请谅解
1) For getting href in clicked context:
var href = $(this).closest('.article-video').find('a').attr('href');
2) For getting the index
var target = $('.article-video').index($(this).closest('.article-video'));
这是我上面的 html,我正在尝试获取我点击的视频的索引,我还需要获取 "owl-video" 锚标记的 href。请参阅下面我尝试过的代码。
- To find the a"href" i tried this, which doesn't seem to work.
var target = $(this).closest('.article-video').index('.article-video').find('a').attr('href');
- this is the code i tried to get the index.
$('.article-video').click(function(){
var target = $(this).closest('.article-video').index('.article-video');
console.log(target);
});
我是 Jquery 的初学者,如有错误,敬请谅解
1) For getting href in clicked context:
var href = $(this).closest('.article-video').find('a').attr('href');
2) For getting the index
var target = $('.article-video').index($(this).closest('.article-video'));