I got a scrolling content controlled via href's in navigation. I use localScroll to scroll the content. So question is how to add class to attribute of currently displayedpart of a content. That's how I initiate scroll
<script style="text/javascript">
$(document).ready(function () {
$('.navigation').localScroll();
});
</script>
Thanks,
Arek
I figured it out:
<script style="text/javascript">
$(document).ready(function () {
$('.navigation').localScroll();
$('.navigation').find('a').click(selectNav);
function selectNav() {
$(this)
.parents('ul:first')
.find('a')
.removeClass('selected')
.end()
.end()
.addClass('selected');
}
function trigger(data) {
var el = $('.navigation').find('a[href$="' + data.id + '"]').get(0);
selectNav.call(el);
}
});
</script>
for that <a>
do you have any id or you want to add class on click of every
if it is something like this <a id="target" >
you can try the below
$('#target').click(function() {
$("p").addClass("myClass yourClass");
});
I was looking into this too, and the answer by @arekk gave me an idea. I implemented mine this way
$('#sub-menu a').click(function(){
var links = $('#sub-menu a');
links.removeClass('selected');
$(this).addClass('selected');
});
I hope this works for anybody looking