18910140161

使用Jquery淡出在

顺晟科技

2021-10-03 13:29:22

148

上单击的任何元素

我对jQuery还是非常陌生的,我不知道为什么它不能工作。 我希望淡出使用jQuery单击的任何元素。

HTML:

<head>
  
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>

  <script src="basicFile.js" defer></script>
  <title>fade Out any clicked on element</title>
</head>
<body>
  <p>
    Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sed magnam nisi animi itaque labore tempore porro iure
    amet accusamus? Eos, similique! Maxime maiores totam rem!
  </p>
  <div>enter code here
    this is another paragraph
  </div>
</body>

脚本:

$(document).ready(
  $('*').on('click',
    () => $(this).fadeOut(2500)
  )
)

我也尝试过:

$(document).ready(
  $('*').click(
    () => $(this).fadeOut(2500)
  )
)

顺晟科技:

$(document).on('click','#elementID', function (){ $(this).fadeOut();})

我想您需要这样的东西:

$(document).ready(function() {
    $(this).click(function(event) {
         $(event.target.id).fadeOut(2500);
    });
});
  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航