Is there a way to passing one to many parameters from html to jQuery?
The requirement is when a link on the page is clicked, toggle some text for this link, and hide text for other link(s), so I have the following jQuery:
$(link1).click(function(){
$(hide1).hide(300, function(){
$(hide2.hide(300, function(){
$(toggle1).slideToggle(300);
});
});
});
If there's five links on the page, I need to repeat the above code 5 time. Any suggestion on how to cut down on repeated code? I was thinking of the following, but somehow not working.
function hideNShow(toggle1, hide1, hide2, hide3, hide4) {
if(hide1) {
$(hide1).hide(300, function(){
if(hide2) {
$(hide2).hide(300, function(){
if(hide2) {
$(hide2).hide(300, function(){
if(hide3) {
$(hide3).hide(300, function(){
if(hide4) {
$(hide4).hide(300, function(){
$(toggle1).slideToggle(300);
});
}
});
}
});
}
});
}
});
}
return false;
};
Any help much appreciated. Thanks, June