.closest.prev jquery无法专注于上面的A标记

.closest.prev jquery无法专注于上面的A标记,jquery,css,Jquery,Css,不确定为什么这不起作用,但我有: 顶部 底部 变量$preDiv=$('.closeEditorLink'); $($preDiv)。单击(函数(){ $($preDiv).closest('.sectionContent a').focus(); }); 我只需要关注上面的一个标记。.closeEditorLink不是.sectionContent A的子项,因此.closest(.sectionContent A”)不会显示任何内容 尝试.closest('.sectionConten

不确定为什么这不起作用,但我有:


顶部
底部
变量$preDiv=$('.closeEditorLink');
$($preDiv)。单击(函数(){
$($preDiv).closest('.sectionContent a').focus();
});

我只需要关注上面的一个标记。

.closeEditorLink
不是
.sectionContent A
的子项,因此
.closest(.sectionContent A”)
不会显示任何内容


尝试
.closest('.sectionContent')。查找('.opena')。焦点()

.closeEditorLink
不是
.sectionContent a
的子项,因此
.closest(.sectionContent a”)
不会显示任何内容


尝试
.closest('.sectionContent')。查找('.opena')。焦点()

尝试如下更改javascript代码:

Jquery:

var preDiv = $('.closeEditorLink');
preDiv.on('click', function () {
    $(this).closest('.sectionContent a').focus();
});


问候

尝试如下更改javascript代码:

Jquery:

var preDiv = $('.closeEditorLink');
preDiv.on('click', function () {
    $(this).closest('.sectionContent a').focus();
});


问候

像下面这样写

jQuery(document).ready(function($){
 var preDiv = $('.closeEditorLink');
  $(preDiv).click(function () {
     $($preDiv).closest('.sectionContent').find('a').focus();
  });
})

像下面这样写

jQuery(document).ready(function($){
 var preDiv = $('.closeEditorLink');
  $(preDiv).click(function () {
     $($preDiv).closest('.sectionContent').find('a').focus();
  });
})

你没有类
closeEditorLink
的锚,它是一个
span
,即使我去掉它,它仍然不起作用你的
$preDiv
已经是一个jquery对象,所以你不需要
$($preDiv)
,只要
$preDiv.点击
$preDiv.closest
,等。你没有类
closeEditorLink
的锚,它是一个
span
,即使我去掉它,它仍然不起作用。你的
$preDiv
已经是一个jquery对象,所以你不需要
$($preDiv)
,只要
$preDiv.点击
$preDiv.closest
,等等。