-3

I have create link on same page . the content of this page is in the bottom and the anchor tab is on the top.

I would like to highlight the content area for 5 seconds when someone clicks on the top link (ancho).

nico
  • 50,859
  • 17
  • 87
  • 112
sajal00
  • 17
  • 2

4 Answers4

3

Take a look at jQuery and the Effects-Plugin.

http://docs.jquery.com/UI/Effects/Highlight

android
  • 652
  • 9
  • 28
1

You can do it in very many ways, for example binding onHashChange and then changing background color:

$(window).bind('hashchange', function(){
    $(".highlight").css("background","#AFA");
    setTimeout(function(){
        $(".highlight").css("background","transparent");
    },5000);
});​

http://jsfiddle.net/X8kBj/1/

Henrik Karlsson
  • 5,559
  • 4
  • 25
  • 42
0

Give each piece of content a unique id as follows:

<div id="content_1"> ... </div>

Then use jQuery to set up events for each link:

$("div").delegate("#content_1", "click", function() {
  $('div.content_1').effect("highlight", {}, 3000);
});

Or you could use .on() or .live() but you get the idea.

Ian Atkin
  • 6,302
  • 2
  • 17
  • 24
  • 2
    Better to use `.on()` and to [not use `.live()`](http://stackoverflow.com/questions/4579117/jquery-live-vs-delegate). – PeeHaa May 21 '12 at 15:38
0

use delay()

$('#id-of-anchor').click(function(){

 $("#your-div").css('background','red').delay(5000).css('background','transparent');
 return false;    

});
Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193