简体   繁体   English

如何使用div和href中的var将js标签与标签内容链接?

[英]how to link js tabs with the tab content using a var in the div and href?

I know it is a silly question, but it annoys me a lot. 我知道这是一个愚蠢的问题,但这让我很烦。

I have a page with tabs. 我有一个带有标签的页面。 I want to generate the tabs dynamicaly using an array and a loop. 我想使用数组和循环动态生成选项卡。 The question is I could not link the tab and the tab content together. 问题是我无法将选项卡和选项卡内容链接在一起。

Here is my example code: 这是我的示例代码:

<div id="tabs">
<ul>
<i a href = '$Tabtitle'>$Tabtitle</a></i>
</ul>

<div id = "$Tabtitle">
<!--tab content-->
</div> 

The result is all tab content are under one tab (they should be separated under different tabs), and changing tabs won't change the tab content. 结果是所有选项卡的内容都在一个选项卡下(它们应该在不同的选项卡下分开),并且更改选项卡不会更改选项卡内容。

I tried to do these: Change href = '#$Tabtitle', not working. 我尝试执行以下操作:更改href ='#$ Tabtitle',不起作用。 change 更改

<div id ="<?php echo $Tabtitle;?>"

still not working. 还是行不通。

Any help is appreciated! 任何帮助表示赞赏!

Sorry for the poor question, but since I resolved the problem, I'd rather put it here in case others may find it useful. 抱歉,这个问题很糟糕,但是由于我已经解决了这个问题,因此我宁愿将其放在此处,以防其他人发现它有用。

The code should be like this: 代码应如下所示:

<div id="tabs">
<ul>
<i a href = 'path/$var#$Tabtitle'>$Tabtitle</a></i>
</ul>

<div id = "$Tabtitle">
<!--tab content-->
</div>

And it works! 而且有效! Thank you! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM