$('.desc-btn').click(function(e) {
$('.desc-btn').removeClass('productview_tab_inactive').addClass('productview_tab_active');
$('.info-btn, .note-btn').removeClass('productview_tab_active').addClass('productview_tab_inactive');
$('.desc-content').show('fast');
$('.info-content').hide('fast');
$('.note-content').hide('fast');
});
$('.info-btn').click(function(e) {
$('.info-btn').removeClass('productview_tab_inactive').addClass('productview_tab_active');
$('.desc-btn, .note-btn').removeClass('productview_tab_active').addClass('productview_tab_inactive');
$('.info-content').show('fast');
$('.desc-content').hide('fast');
$('.note-content').hide('fast');
});
$('.note-btn').click(function(e) {
$('.note-btn').removeClass('productview_tab_inactive').addClass('productview_tab_active');
$('.desc-btn, .info-btn').removeClass('productview_tab_active').addClass('productview_tab_inactive');
$('.note-content').show('fast');
$('.info-content').hide('fast');
$('.desc-content').hide('fast');
});
這是我寫的
但我發現似乎可以再簡化?但我已經想不到
想問線上的大神的簡化寫法。
補充
果然有,感謝各位大神,太神啦
好热闹。我也试试,题目没有给出html结构,所以答题时我就自由发挥了。
以下是完整的css,js,html DEMO