在 JQuery 中进行选项卡选择有什么问题?
我想创建一个网页,在其中可以通过侧边栏和 jQuery 选项卡本身的上部按钮栏使用 jQuery 选项卡。
我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1" />
<title>title here</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="ui.core.js"></script>
<script type="text/javascript" src="ui.datepicker.js"></script>
<script type="text/javascript" src="ui.tabs.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="local.css" />
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker();
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
});
$("select2").click(function() { // bind click event to link
$("$tabs").tabs("select", 1); // switch to third tab
return false;
});
</script>
</head>
<body>
<div id="container">
<div id="row">
<div id="leftsubcontainer"><div class="column-in">
<h4>rev0.1</h4>
<p>medewerkernaam</p>
<br/>
<div type="text" id="datepicker"></div>
<br/><br/>
<br/><br/>
<p>log out</p>
<button id="select2">kies derde</button>
<br/><br/>
</div></div>
<div id="rightsubcontainer"><div class="column-in">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
<p>tekst1</p>
</div>
<div id="tabs-2">
<p>tekst 2</p>
</div>
<div id="tabs-3">
<p>tekst 3</p>
</div>
</div>
</div></div>
</div>
</div>
</body>
</html>
问题是,每当我单击按钮时,选项卡都不会更改(即它没有选择正确的选项卡)。
有谁知道我做错了什么?
I want to create a webpage in which I can use the jQuery tabs both by a side-bar and by the upper button-bar of the jQuery tabs itself.
My code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1" />
<title>title here</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="ui.core.js"></script>
<script type="text/javascript" src="ui.datepicker.js"></script>
<script type="text/javascript" src="ui.tabs.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="local.css" />
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker();
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
});
$("select2").click(function() { // bind click event to link
$("$tabs").tabs("select", 1); // switch to third tab
return false;
});
</script>
</head>
<body>
<div id="container">
<div id="row">
<div id="leftsubcontainer"><div class="column-in">
<h4>rev0.1</h4>
<p>medewerkernaam</p>
<br/>
<div type="text" id="datepicker"></div>
<br/><br/>
<br/><br/>
<p>log out</p>
<button id="select2">kies derde</button>
<br/><br/>
</div></div>
<div id="rightsubcontainer"><div class="column-in">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
<p>tekst1</p>
</div>
<div id="tabs-2">
<p>tekst 2</p>
</div>
<div id="tabs-3">
<p>tekst 3</p>
</div>
</div>
</div></div>
</div>
</div>
</body>
</html>
The problem is, that, whenever I click on the button, the tabs are not changing (i.e. it does not select the right tab).
Does anyone know what I have been doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一个问题:
您应该使用 # 而不是 $ :
并且传递 1 作为第二个参数将选择第二个选项卡,而不是第三个选项卡。
You have a problem here :
You should use a # instead of $ :
And passing 1 as second parameter will select second tab, not third.
小细节但是:
可以合并到:
Minor detail but:
could be merged into: