Okay guys, I greet you all! I have been having this newbie question in jquery. I love the great animations that jquery can do and all those cool Mozilla stuff! Okay that's by the way! I have a couple of DIV elements with different IDs that i have been trying to show/hide through a function passed into javascripts onclick() method. I have gone through a couple of a examples presented in the Questions section, but I don't understand why what am doing isn't working!
Now this is my jquery code:
$(document).ready(function(){
var toggle_btn = $('.toggle-button');
var contentToggle = function(element){
toggle_btn.click(function(e){
If($(this).hasClass('switch-off')){
$(this).removeClass('switch-off');
$(this).addClass('switch-on');
$('#' element).hide();
}else{
$(this).removeClass('switch-on');
$(this).addClass('switch-off');
$('#' element).show();
}
e.preventDefault();
});
}
contentToggle();
});
The following is path of my html:
<a href='' onclick='contentToggle('color-list') class='toggle-button switch-off'>
<div id="color-list">Container Contents</div>
And my css:
#color-list{display:none;}
Unfortunately, this doesn't seem to work however I tried! Please can you guys help point me in the right direction? What haven't I done correctly?