jquery 选项卡 - 我无法制作我的
这是我的选项卡式界面,我有一个 jsfiddle 这里。
<div class="tabs">
<!-- tabs -->
<ul class="tabNavigation">
<li><a href="#corporations">Corporations</a></li>
<li><a href="#non-profit">non-profit</a></li>
<li><a href="#growing-businesses">growing-businesses</a></li>
<li><a href="#arrange">Arrange a meetup</a></li>
</ul>
<!-- tab containers -->
<div id="corporations">
<p>Lorem ipsum dolor sit amet.</p>
</div>
<div id="non-profit">
<p>Sed do eiusmod tempor incididunt.</p>
</div>
<div id="growing-businesses">
<p>Ut enim ad minim veniam</p>
</div>
<div id="arrange">
<p>Sed do ad minim ipsum dolor sit</p>
</div>
</div>
这是我的jquery,它很简单。
$(function () {
var tabContainers = $('div.tabs > div');
$('div.tabs ul.tabNavigation a').click(function () {
tabContainers.hide().filter(this.hash).show();
$('div.tabs ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
我的问题是我知道如何轻松操作 以便更改悬停或单击时的内容,我已经在 jsfiddle 中完成了这一点。但我想将鼠标悬停或单击
并更改容器中要显示的信息。
This is my tabbed interface, I have a jsfiddle here.
<div class="tabs">
<!-- tabs -->
<ul class="tabNavigation">
<li><a href="#corporations">Corporations</a></li>
<li><a href="#non-profit">non-profit</a></li>
<li><a href="#growing-businesses">growing-businesses</a></li>
<li><a href="#arrange">Arrange a meetup</a></li>
</ul>
<!-- tab containers -->
<div id="corporations">
<p>Lorem ipsum dolor sit amet.</p>
</div>
<div id="non-profit">
<p>Sed do eiusmod tempor incididunt.</p>
</div>
<div id="growing-businesses">
<p>Ut enim ad minim veniam</p>
</div>
<div id="arrange">
<p>Sed do ad minim ipsum dolor sit</p>
</div>
</div>
This is my jquery which is simple enough.
$(function () {
var tabContainers = $('div.tabs > div');
$('div.tabs ul.tabNavigation a').click(function () {
tabContainers.hide().filter(this.hash).show();
$('div.tabs ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
My problem is I know how to easily manipulate an <a>
in order to change the contents on hover or click, which I have already done in the jsfiddle. But I want to hover or click the <li>
and change the information in the container to show.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要做的就是选择
元素并绑定
click
事件处理程序,就像链接一样:这是 jsfiddle 的更新版本: http://jsfiddle.net/3EyCT/5/
All you need to do is select the
<li>
elements and bind aclick
event handler, just the same as for a link:Here is an updated version of your jsfiddle: http://jsfiddle.net/3EyCT/5/