user1091558 user1091558 - 3 months ago 31
jQuery Question

jQuery show() function display inline block. How?

I have some code like this

function switch_tabs(obj)
{
$('.tab-content').hide();
$('.tabs a').removeClass("selected");
var id = obj.attr("rel");

$('#'+id).show();
obj.addClass("selected");
}


Show function adds display:block.
But i would like to add display:inline-block instead of block.

Can someone help me?
Thanks

Answer

Instead of show, try to use CSS to hide and show the content.

function switch_tabs(obj) {
    $('.tab-content').css('display', 'none'); // you could still use `.hide()` here
    $('.tabs a').removeClass("selected");
    var id = obj.attr("rel");

    $('#' + id).css('display', 'inline-block');
    obj.addClass("selected");
}