That will certainly work, however I'd like to propose an alternative.
HTML
Toggle
jQuery/JavaScript
$(document).ready(function(){
$('a.toggle').click(function (eventObject){
var target = $(eventObject.target);
// will add or remove the class automatically
target.toggleClass('toggle_on');
if(target.hasClass('toggle_on')){
/* toggle on code here */
alert('Toggle On');
}
else{
/* toggle off code here */
alert('Toggle Off');
}
});
});
This gets you out of having to use the href attribute for the toggles and lets you control things through styling and whatnot. Though my experience with jQuery is not all that extensive something like this seems a bit more conventional.