how to highlight a div for a few seconds using jQuery

前端 未结 5 2224
無奈伤痛
無奈伤痛 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:49

    You can use the jQuery UI's Highlight Effect:

    $(".myDiv").effect("highlight", {}, 3000);
    

    Demo in Stack Snippets:

    $(function() {
    
      $(".myDiv").click(function() {
        $(this).effect("highlight", {}, 3000);
      });
    
    });
    .myDiv {
      margin: 0px;
      width: 100px;
      height: 80px;
      background: #666;
      border: 1px solid black;
      position: relative;
    }
    
    
    
    
    
    

提交回复
热议问题