Skip to content

Instantly share code, notes, and snippets.

@program247365
Created January 11, 2012 16:06
Show Gist options
  • Save program247365/1595369 to your computer and use it in GitHub Desktop.
Save program247365/1595369 to your computer and use it in GitHub Desktop.
A small jquery component switch widget.
var switchComponent = {
init : function(){
var firstSwitch = ".swfirst";
var secondSwitch = ".swsecond";
var compContent = $(".componentscontent");
var envContent = $(".environmentscontent");
$(firstSwitch).click(function() {
$(this).css({background: '#eaefd8', color: '#000', borderRight: '2px solid #d6e1b4'});
$(secondSwitch).css({background: '#e0e8c6', color: '#ccc', borderLeft: '2px solid #ccc'});
$(compContent).hide();
$(envContent).show();
});
$(secondSwitch).click(function() {
$(this).css({background: '#eaefd8', color: '#000', borderLeft: '2px solid #d6e1b4'});
$(firstSwitch).css({background: '#e0e8c6', color: '#ccc', borderRight: 'none', borderRight: '2px solid #ccc'});
$(compContent).show();
$(envContent).hide();
});
}
}
$(document).ready(switchComponent.init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment