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.
精彩评论