如何使 Jquery 选项卡既能鼠标悬停又能单击打开页面?

发布于 2024-08-10 16:43:29 字数 643 浏览 5 评论 0原文

它不会让我提交多个链接,所以请发挥你的想象力,我需要多个带有多个鼠标悬停或图像的选项卡,以便中间的东西是一张图像

<script type="text/javascript">
$(function() {
$("#tabs").tabs({event: 'mouseover'}).addClass('ui-tabs-vertical ui-helper-clearfix');
$("#tabs li").removeClass('ui-corner-top').addClass('ui-corner-right');
$('.openpage').click(function(){
  window.location=$(this).attr('title');
    });
});
</script>

<div id="tabs">
<ul>
<li><a href="#tabs-1" title="content1.html" class="openpage">content1</a></li>
</ul>
<div id="tabs-1"><imgimg src="/images/1.jpg" alt=""></div> 
</div>

it wont let me submit more than one link, so please use your imagination, i need multiple tabs with mutliple mouse overs or images so that thing in the middle is an image

<script type="text/javascript">
$(function() {
$("#tabs").tabs({event: 'mouseover'}).addClass('ui-tabs-vertical ui-helper-clearfix');
$("#tabs li").removeClass('ui-corner-top').addClass('ui-corner-right');
$('.openpage').click(function(){
  window.location=$(this).attr('title');
    });
});
</script>

<div id="tabs">
<ul>
<li><a href="#tabs-1" title="content1.html" class="openpage">content1</a></li>
</ul>
<div id="tabs-1"><imgimg src="/images/1.jpg" alt=""></div> 
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗失的美好 2024-08-17 16:43:29

此代码取自 jQuery 文档

HTML 代码。请注意,我已经添加了选项卡类。

<div id="tabs">
    <ul>
        <li class="tab1"><a href="#fragment-1"><span>One</span></a></li>
        <li class="tab2"><a href="#fragment-2"><span>Two</span></a></li>
        <li class="tab3"><a href="#fragment-3"><span>Three</span></a></li>
    </ul>
    <div id="fragment-1">
        <p>First tab is active by default:</p>
        <pre><code>$('#example').tabs();</code></pre>
    </div>
    <div id="fragment-2">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
    <div id="fragment-3">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
</div>

现在,如果您想在选项卡上添加多种效果,您所要做的就是以下内容:

  $(document).ready(function(){
    $("#tabs").tabs();
    $("#tabs .tab1").click(function() { alert('hello world'); });
  }); 

我还没有对此进行测试,但我认为它应该可以工作。

This code is taken from jQuery Docs.

HTML code. Note that I've added classes for tabs.

<div id="tabs">
    <ul>
        <li class="tab1"><a href="#fragment-1"><span>One</span></a></li>
        <li class="tab2"><a href="#fragment-2"><span>Two</span></a></li>
        <li class="tab3"><a href="#fragment-3"><span>Three</span></a></li>
    </ul>
    <div id="fragment-1">
        <p>First tab is active by default:</p>
        <pre><code>$('#example').tabs();</code></pre>
    </div>
    <div id="fragment-2">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
    <div id="fragment-3">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
</div>

Now, if you want to add multiple effects on tabs, all you have to do is the following:

  $(document).ready(function(){
    $("#tabs").tabs();
    $("#tabs .tab1").click(function() { alert('hello world'); });
  }); 

I've not tested this, but I think it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文