[Solved] jQuery – Change Image When Tab is Clicked


Here is a way to do what you want using jQuery UI tabs. It uses the “show” event to detect which ui.panel element is being displayed.

​$('#tabs').tabs({
  show: function(e,ui){
    switch(ui.panel){
      case $('#tabs-1')[0]: src="https://stackoverflow.com/questions/9985911/image1.jpg"; break;
      case $('#tabs-2')[0]: src="image2.jpg"; break;
      default: src="default.jpg";
    }
    $('#myimg').attr('src',src);
  }
});​​​​​

In the future, I’d recommend adding more specifics to your question, and providing a more simplified example. Your page had numerous scripts on it, which makes it difficult to look at your specific situation.

2

solved jQuery – Change Image When Tab is Clicked