how to highlight a div for a few seconds using jQuery

前端 未结 5 2219
無奈伤痛
無奈伤痛 2021-02-08 01:04

I want to be add the following to a a page:

When a div is clicked, I want to:

  1. change the background color of the clicked on div for a few seconds
5条回答
  •  难免孤独
    2021-02-08 01:42

    For posterity, here is an answer involving the jQuery queue() function.

    $('.menul').addClass('red').delay(1000).queue(function(next){
       $(this).removeClass('red');
       next();
    });
    

    From: https://forum.jquery.com/topic/inserting-a-delay-between-adding-and-removing-a-class#14737000002257187

提交回复
热议问题