我有这段代码:
<ul id="tabsss">
<li class="underUl"> <a href="about.php#History"> - History</a></li>
<li class="underUl"><a href="about.php#Concept"> - The Concept</a></li>
<li id="cst1" class="underUl"><a href="about.php#Choose_CST"> - Why Choose CST?</a></li>
<li id="management1" class="underUl">- Management</li>
<li id="department1" class="underUl">- Department</li>
</ul>
在另一个页面中,我有<div>
<div class="tab-pane active" id="History">test</div>
<div class="tab-pane" id="Concept">test1</div>
<div class="tab-pane" id="Choose_CST">ssss</div>
<div class="tab-pane" id="Management">ssss</div>
<div class="tab-pane" id="Department">ssss</div>
我想转到其他页面中的特定标签。现在它只打开第一个。
有人帮忙吗?提前谢谢。
答案 0 :(得分:0)
我再次阅读您的问题,可以使用JavaScript轻松实现:
$(document).ready(function(){
url_params = window.location.hash;
tabParams = $('a[href="' + url_params + '"]');
console.log(tabParams);
console.log(url_params);
if (tabParams.length === 0)
{
//Activate first tab
//Show first tab content
}
else
{
tabParams.click();
}
});
答案 1 :(得分:0)
加载第二页时,您需要添加一些javascript。
类似的东西:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
GenresFragment genresFragment = new GenresFragment();
// getFragmentManager().beginTransaction().replace(R.id.container,new GenresFragment()).commit();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.container, genresFragment);
transaction.commit();
如果您在about页面上有标签,可以这样做:
if (window.location.hash == "History"){
$('.tab').hide(); //hide all other tabs
$('#History').show();
}