Highlight A Specific Div Depending On Url
I have a list of FAQs on, say, page faq.html like so:
...
...
I now want to pulsate or simply highlight one of thSolution 1:
If you can ad a fragment to the URL you can use the CSS :target
pseudo-class.
HTML:
<a href="#see"id="see">See</a> <a href="#works"id="works">works</a> <a href="#well"id="well">well</a>
CSS:
a:target{
transition:background-color 1s ease-in;
-webkit-transition:background-color 1s ease-in;
-moz-transition:background-color 1s ease-in;
background-color: yellow;
}
Solution 2:
for highlighting it you can do this
varBlinkcnt = 0;
functionBlinkDiv(DivId) {
if (Blinkcnt % 2 == 0) {
$('#' + DivId).animate({ backgroundColor: "#E1E1E1" }, 500);
Blinkcnt += 1;
}
else {
$('#' + DivId).animate({ backgroundColor: "#F8F8F8" }, 500);
Blinkcnt += 1;
}
if (Blinkcnt < 10) {
setTimeout(function () {
BlinkDiv();
}, 500);
}
else {
Blinkcnt = 0;
$('#' + DivId).animate({ backgroundColor: "#F8F8F8" }, 500);
}
}
Solution 3:
You can use this using the CSS :target
selector (so to target faq2
only when the fragment is #faq2
, use faq2:target
{ ... }
).
Also to animate it, look into CSS3 transitions and keyframes.
Solution 4:
$(function() {
var params = window.location.href.split('?')[1].trim().split('&');
var location = '';
for( var i=0; i<params.length; i++ ) {
var pair = params[i].split('=');
location = pair[0] ==='highlight' ? pair[1] : '';
}
if ( location ) {
$('#'+location).effect("highlight", {}, 3000);
// or $('#'+location).effect("pulsate", { times:3 }, 2000);
}
});
http://docs.jquery.com/UI/Effects/Highlighthttp://docs.jquery.com/UI/Effects/Pulsate
Post a Comment for "Highlight A Specific Div Depending On Url"