I have the following image map that relate to anchor points in this table.
<table id="itemslist" class="table">
<tbody>
<tr data-position="1">
<td>Position<a name="anchor1"></a></td>
<td>1</td>
</tr>
<tr data-position="2">
<td>Position<a name="anchor2"></a></td>
<td>1</td>
</tr>
</tbody>
</table>
<map name="imgMap">
<area shape="rect" coords="465,140,485,159" href="#anchor1">
<area shape="rect" coords="112,161,131,180" href="#anchor2">
</map>
When the user click one position the page scroll to where that anchor is. But I need the page to scroll a little higher up and I cannot move the html anchor points. How can I accomplish this using jQuery?
Is it possible to iterate over each anchor element in the table and use jQuery to scroll to that position minus a value?
for example..
function scrollToAnchor(id) {
var aTag = jQuery("a[name='"+ id +"']");
jQuery('html,body').animate(
{
scrollTop: aTag.offset().top - 150
},'fast');
};