I've got this script on my website:
$(document).ready(function() {
function filterPath(string) {
return string
.replace(/^\//,'')
.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
.replace(/\/$/,'');
}
$('[href*=#]').each(function() {
if ( (filterPath(location.pathname) == filterPath(this.pathname))
&& (location.hostname == this.hostname)
&& (this.hash.replace(/#/,'')) ) {
var $targetId = $(this.hash),
$targetAnchor = $('[name=' + this.hash.slice(1) +']');
var $target = $targetId.length
? $targetId
: $targetAnchor.length ? $targetAnchor : false;
if ($target) {
var divOffset = $target.parent().offset().top;
var pOffset = $target.offset().top;
var pScroll = pOffset - divOffset;
$(this).click(function() {
$target.parent().animate({scrollTop: pScroll + 'px'}, 600);
return false;
});
}
}
});
});
It works well, and scrolls the main nav div
s up and down etc. but I want the div
s inside the services section to scroll left and right. I also want to add a slider to the portfolio section but the above code over rules any additional code as it's applied to all <a href...>
tags. How do I only specify it to the mainnav ul
?
thanks in advance