Is it possible to scroll to an element with a specific id and a specific class. For example a simple script for smooth scrolling to a specific id is
$(function () {
$('a[href*="#"]').click(function () {
var $target = $(this.hash);
$target = $target.length ? $target : $('html');
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, {duration: 1500, easing: 'easeInOutCubic'});
return false;
});
});
This is useful if you have something like
<div id="space-red"></div>
<div id="space-blue"></div>
<div id="space-green"></div>
However if you have a page such as
<div id="space-red" class="class1"></div>
<div id="space-blue" class="class1"></div>
<div id="space-red" class="class2"></div>
<div id="space-blue" class="class2"></div>
<div id="space-green" class="class1"></div>
Would you be able to navigate between the two space-red
or space-blue
ids by differentiating between the classes they have assigned to them?