, , .
, return false; jQuery event.preventDefault();. , , , jQuery, , .
Javascript:
$('.source-title-box a').click(function(event) {
event.preventDefault();
if($(this).closest('div').hasClass('active')) {
return false;
}
$('.active').toggleClass('active');
$(this).closest('div').toggleClass('active');
var region = $(this).attr('data-region');
$('.textzone:visible').fadeOut(500, function () {
$('#' + region).fadeIn(500);
});
});β
CSS:
.active {
background-color:#467FD9;
color:#fff;
}
.active a {
cursor:default;
color:#fff;
}
A :
http://jsfiddle.net/dmvcQ/3/
, HTML , <a href="#" data-region="source-region">Our region</a>, <div> <span>.
For example, here is the same code with only anchor tags: http://jsfiddle.net/dmvcQ/7/
Let me know if you have any questions regarding the answer.
source
share