jQuery.show没有在.each中工作

jQuery .show not working in .each

本文关键字:each 工作 show jQuery      更新时间:2023-09-26

这是我的jquery代码。我想展示一下。这是我的代码

 $('#divTalentAgent a').each(function () {
        $(this).show();
    });

上面的代码不起作用。但如果我把它修改为以下

 $('#divTalentAgent a').each(function () {
        alert('hi');
        $(this).show();
    });

它有效。。

正确的代码是:

$('#divTalentAgent a').show();

试试这个

 $('#divTalentAgent a').each(function () {
   setTimeout(function(){$(this).show();},0);       
});

尝试这个

 $(document).ready(function(){
     $('#divTalentAgent a').show();
 });

其工作

jQuery(document).ready(function() {
$('li').each(function () {
        alert('hi');
        $(this).show();
    });
      });

演示