dongshandun4363
2009-02-20 06:36
浏览 41
已采纳

如何在表中搜索jQuery中单词的定义?

This is a little hard to explain, but I have an HTML table, full of SQL definitions, that cross-talk a great deal. For example, one is talking about "INSERT statements", and mentions a "unique key". Another one of the rows talks about unique keys.

I'd like to create little definition bubble (when you hover over "unique key" in the INSERT row) with the definition from the appropriate row. I was planning on using jQuery, but I'm open to alternatives. Any ideas?

UPDATE: My code is here

图片转代码服务由CSDN问答提供 功能建议

这有点难以解释,但我有一个HTML表,充满了SQL定义,这是串扰 好的折扣。 例如,一个人在谈论“INSERT语句”,并提到“唯一键”。 另一行讨论了唯一的密钥。

我想创建一个定义气泡(当您将鼠标悬停在INSERT行中的”唯一键“上)时,使用相应行中的定义。 我打算使用jQuery,但我愿意接受其他选择。 有什么想法吗?

更新:我的代码是这里< / a>

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dongyihang3575 2009-02-20 06:43
    已采纳

    There are a few jQuery tooltip plug-ins (which is really what you're after). Personally I've been using jQuery Tooltip and am happy with it. I've used it to put some pretty complex content in a tooltip.

    I don't fully understand the rest of your question. Do you want this to happen automatically? Is the table present on the page? Is server side code creating the definition bubbles?

    Now jQuery Tooltip has a bodyHandler attribute where you can supply a callback (function) that'll define the content of the tooltip so that bit's fine. Do you want these links/tips automatically created though?

    EDIT: Take a look at this highlight plug-in as well. Even if you don't use it you can copy the methods for finding text in your document and wrapping elements around them. Something like:

    $(function() {
      $("table.definitions th").each(function() {
        var term = $(this).text();
        var definition = $(this).nextSibling().text(); // assuming it's in a <td> in the same row
        // find all occurrences of 'term' in relevant text block
        // and wrap in <span class="term" title="definition">...</span>
      });
    });
    

    Then optinoally use jQuery Tooltip to make a more modern tooltip out of that title.

    评论
    解决 无用
    打赏 举报
查看更多回答(3条)

相关推荐 更多相似问题