简体   繁体   中英

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. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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