I am trying to make some tabs with the Jquery ui.
My html looks lie this…
<html>
<head>
<!--use for jquery-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<!--external javascript source-->
<script type= "text/javascript" src= "javascript/home_scripts.js"> </script>
<!--css-->
<link rel="stylesheet" type="text/css" href="css/homepage.css" />
</head>
<body>
<ul class="tabs">
<li><a href="#">Tab 1</a></li>
<li><a href="#">Tab 2</a></li>
<li><a href="#">Tab 3</a></li>
</ul>
<div class="panes">
<div>First tab content. Tab contents are called "panes"</div>
<div>Second tab content</div>
<div>Third tab content</div>
</div>
</body>
</html>
and my javascript file looks like so
$(function() {
// setup ul.tabs to work as tabs for each div directly under div.panes
$("ul.tabs").tabs("div.panes > div");
});
The problem is that when I load my page, there are no tabs. It looks like this
Tab 1
Tab 2
Tab 3
First tab content. Tab contents are called "panes"
Second tab content
Third tab content
What have I done wrong? I tried to follow the tutorial as best as I could.
Change your markup to:
and your JavaScript to:
The
.tabs()function does not take a selector as a parameter. It uses theinnerHTMLstructure of the selected element to make the tabs. Ideally, thehrefon your anchors should point to anidon the corresponding “pane”