开发者

Highlight by coloring a div on page load (without using jQuery UI)

开发者 https://www.devze.com 2023-01-25 07:15 出处:网络
I just need to highlight a div by changing its background color for just a moment on page load. I dont want to include jQuery UI plugin just for this.

I just need to highlight a div by changing its background color for just a moment on page load. I dont want to include jQuery UI plugin just for this.

Is there is any way to do this just by pure jQuery 1.开发者_运维百科4?


$("div").addClass("highlight");
    setTimeout(function() {$("div").removeClass("highlight");}, 500);


.highlight {
      background: red;
}


Perhaps something like this

HTML:
<div id="div1" class="someclass">Text</div>

JQuery:
$("div.someclass").css("background-color":"red");

or

$("#div1").css("background-color":"red");

I use this often to make sure that the script is picking up the right element or an element.

0

精彩评论

暂无评论...
验证码 换一张
取 消