开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜