如何在 jQuery 手风琴上使用 jQuery 工具提示

本文关键字:jQuery 工具提示 手风琴 | 更新日期: 2024-10-24 18:31:15

谁能告诉我如何在jQuery手风琴控件上使用jQuery工具提示?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.10.3.custom.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#Accord').accordion(
                {
                    create: function (event, ui) {
                        $('.ui-accordion-header').attr("disabled", true);
                    }
                });
        })
        $(document).tooltip();
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="row" id="Accord">
            <h2>Getting started</h2>
            <div class="col-md-4">
                <p>
                    ASP.NET Web Forms lets you build dynamic websites using a familiar drag-and-drop, event-driven model.
            A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.
                </p>
                <p>
                    <a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301948">Learn more &raquo;</a>
                </p>
            </div>
            <h2>Get more libraries</h2>
            <div class="col-md-4">
                <p>
                    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.
                </p>
                <p>
                    <a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301949">Learn more &raquo;</a>
                </p>
            </div>
            <h2>Web Hosting</h2>
            <div class="col-md-4">
                <p>
                    You can easily find a web hosting company that offers the right mix of features and price for your applications.
                </p>
                <p>
                    <a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301950">Learn more &raquo;</a>
                </p>
            </div>
        </div>
    </form>
</body>
</html>

以上是我的示例代码。请指导我如何将工具提示与手风琴集成?我想在将鼠标悬停在手风琴的标题上时获取面板的某些内容.

如何在 jQuery 手风琴上使用 jQuery 工具提示

无需使用任何插件。 自己写就行了。您可以将要悬停在悬停时显示的内容放在自定义属性(或例如rel属性(中,并获取其值并以jQuery生成的绝对定位范围显示它。

例如:

.HTML:

<h2 rel="YOUR CONTENT GOES HERE">Web Hosting</h2>

jquery:

$(function(){
    var ttContent = $('h2').attr('rel');
    $('h2').hover(function(){
        $(this).append('<span class="ttbox">' + ttContent + '</span>');
    },function(){
        $(this).children('.ttbox').remove();
    });
});

.CSS:

 h2 { position:relative; }
.ttbox { position:absolute; display:none; top:20px; width:200px; height:30px; display:block; background:#000; color:#fff; }

小提琴演示