Hi,
How can i add a function to all links which share a same class on page read? I want to add this addClassSub(); to all the links with a class name 'sub'.
this is the html,
PHP Code:
<li class="sub"><a href="#">1</a></li>
<li class="sub"><a href="#">2</a></li>
<li class="sub"><a href="#">3</a></li>
this is the jquery and functions,
Code:
$(document).ready(function(){
$(".sub").click(function () {
addClassSub();
return false;
});
});
function addClassSub() {
$(".sub").click(function () {
removeClassSub();
$(this).addClass("current");
});
}
function removeClassSub() {
$(".sub").removeClass("current");
}
many thanks,
Lau