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.

显示功能添加显示:块。但是我想添加显示:inline-block而不是block。

Can someone help me? Thanks

有人能帮助我吗?谢谢

12 个解决方案

#1


177

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

不要显示,尝试使用CSS来隐藏和显示内容。

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");
}

更多相关文章

  1. 想要改进我的jQuery代码,做我想要的,太丑了,IMO
  2. JQuery的一些基本功能代码(CH1&2)
  3. 如何在angularjs代码中单元测试jquery元素
  4. [置顶] JQuery datatables 使用Fixedcolumns固定列控件
  5. jquery常用代码片段
  6. Webhoster插入了一个javascript,它会阻止我的代码如何删除它?
  7. 可以直接拿来用的15个jQuery代码片段
  8. 为什么使用observe_field代码不能使用JQuery模型对话框?
  9. jQuery Ui Draggable在移动端浏览器不起作用解决方案

随机推荐

  1. android在处理一写图片资源的时候,会进行
  2. android sim卡 TelephonyManager类:Androi
  3. 【自学Android】使用ModelView,DataBindi
  4. Android动画学习笔记-Android Animation
  5. android 开启Https单向认证
  6. textview设置文本每行的行间距
  7. Android如何设置TextView的行间距、行高
  8. Eclipse安装Android教程
  9. Launcher研究资料收集(3)--.LauncherAppl
  10. [转]Android 技术专题系列之九 -- 图形系统