如何突出显示选定的jQuery UI选项卡? [英] how to highlight selected jquery ui tab?

查看:105
本文介绍了如何突出显示选定的jQuery UI选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 http://jqueryui.com/tabs,并自定义外观.我一直在网上搜索如何通过在某人点击某个选项卡时更改其背景颜色来突出显示该选项卡.到目前为止,它一直很沮丧并且没有成功.

I've learned how to create a jquery ui tab, thanks to http://jqueryui.com/tabs, and customized the look of it. I've been searching the web on how to highlight a selected tab by changing it's background color when someone clicks on it. So far, it's been frustrated and unsuccessful.

这是 HTML代码使用:

<!DOCTYPE html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" >

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.js"></script>

 <script>
$(function() {
$( "#tabs" ).tabs();
});
</script>

<title>Jquery Tab Test</title>
</head>

<body>

<div id="tab-wrapper">
<div id="tabs">

<ul>
    <li><a href="#tabs1">Tab 1</a></li>
    <li><a href="#tabs2">Tab 2</a></li>
    <li><a href="#tabs3">Tab 3</a></li>
</ul>

<br class="clearboth" />

<div id="tabs1" class="tab-content">
Content 1
</div>

<div id="tabs2" class="tab-content">
Content 2
</div>

<div id="tabs3" class="tab-content tabs3">
Content 3
</div>

</div>
</div>

</body>

CSS :

body, html {
    height: 101%;
}

body {
    font-family: arial;
}

.clearboth {
    clear: both;
    padding: 0;
    margin: 0;
}
#tab-wrapper {
    background-color: #f00fff;
    border: solid 1px #909090;
    padding: 5px;
    width: 330px;
}

#tabs {
    overflow: hidden;
}

#tabs ul li,
#tabs ul { 
    margin: 0;
    padding: 0;
    list-style: none;
}

#tabs ul a {
    float: left;
    padding: 5px;
    display: block;
    width: 100px;
    text-align: center;
    text-decoration: none;
    color: #000000;
    height: 20px;
    line-height: 20px;
    font-size: 10pt;
    font-weight: bold;
    background-color: #cccccc;
}

#tabs ul a:hover {
    background-color: #f1f1f1;
}

#tabs .tab-content {
    padding: 5px;
    display: block;
    background-color: #f1f1f1;
    font-size: 10pt;
    height: 300px;
    border-top: solid 1px #000000;
}

请帮助.

推荐答案

jquery将选定的选项卡分配为class ="ui-tabs-active",以便对其进行样式设置,只需将css挂接到它,如下所示:

Jquery assigns the selected tab the class="ui-tabs-active" so to style it simply hook your css into it as follows:

#tabs .ui-tabs-active {
  background: yellow;
}

这篇关于如何突出显示选定的jQuery UI选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆