如何在jQuery show()函数中添加display:inline-block? [英] How to add display:inline-block in a jQuery show() function?
本文介绍了如何在jQuery show()函数中添加display:inline-block?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些类似这样的代码:
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函数添加display:block
.但是我想添加display:inline-block
而不是块.
The show function adds display:block
. But I would like to add display:inline-block
instead of block.
推荐答案
而不是show
,请尝试使用CSS隐藏和显示内容.
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");
}
这篇关于如何在jQuery show()函数中添加display:inline-block?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文