We would like to know how to click to highlight with jquery / css3 animation.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.8.3.js'></script>
<style type='text/css'>
#status {<!-- w w w .j a v a 2s. co m-->
padding: 5px;
text-align: center;
-webkit-transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
}
#status.alert {
background: #EEE; /* IE */
background: rgba(255, 255, 0, 0.5); /* Everyone else */
}
</style>
<script type='text/javascript'>
$(window).load(function(){
function message (msg) {
$("#status").text(msg).clearQueue().queue(function (next) {
$(this).addClass("alert"); next();
}).delay(400).queue(function (next) {
$(this).removeClass("alert"); next();
});
}
$("#do-something").click(function() {
message("Clicked! ")
});
});
</script>
</head>
<body>
<div id="status">Default message</div>
<button id="do-something">Do something</button>
</body>
</html>
The code above is rendered as follows: