gpt4 book ai didi

jquery - 不会收到 :focus event?

转载 作者:太空宇宙 更新时间:2023-11-03 23:32:39 25 4
gpt4 key购买 nike

这是 HTML:

              <fieldset>
<legend>FieldsetName</legend>
<div></div>
</fieldset>

这是 CSS:

legend:focus {
background-color: #ffddbe;
outline: none;
}
legend.focusin {
background-color: #ffddbe;
outline: none;
}

点击它不会执行任何操作。

好吧,我想,我会选择 jQuery。

$('legend').focusin( function() {
$(this).addClass('focusin');
});

$('legend').focusout( function() {
$(this).removeClass('focusin');
});

这也无济于事。但是,如果 $('legend') 监听“click”,它就会执行它应该执行的操作。给了什么?

最佳答案

不确定它是否是正确的修复,但添加 tabIndex 修复它

<legend tabIndex="1">FieldsetName</legend>

演示:Fiddle

关于jquery - <legend> 不会收到 :focus event?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24911321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com