jquery - 我如何使用jquery获取这个div的内容

标签 jquery asp.net-mvc qtip

当我突出显示“class=div”内的任何文本时,我想显示工具提示。我有以下 HTML:

<div class='test'>Test</div>
<div class='tooltip'>Tooltip 1</div>

<div class='test'>Test 2</div>
<div class='tooltip'>Tooltip 2</div>

<div class='test'>Test 4</div>
<div class='tooltip'>Tooltip 4</div>

以及以下 JavaScript:

<script type="text/javascript">
        $(document).ready(function () {

            $('div.test').each(function () {

                var tooltipHtml = //NEED to figure out how get the html of the Tooltip div below this current div
                $(this).qtip({
                    content: {
                        text: tooltipHtml
                    },
                    style: { width: 450 }
                });
            });
        });

如何从“下一个”工具提示 div 获取 html?

最佳答案

1:使用 jQuery next()选择它。

var tooltipHtml = $(this).next('.tooltip').html();

关于jquery - 我如何使用jquery获取这个div的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3381871/

相关文章:

jquery - 在私有(private)商业应用程序中使用 jQuery

asp.net-mvc - 在asp.net mvc中使用fileupload时如何防止IE保存文件对话框

css - 在跟随链接后的下一页中添加 css 类(asp.net-mvc razor)

jquery - qTip2在Chrome中的定位

jquery - 使用 qTip jQuery 插件进行 ASP.NET MVC 验证

JQuery QTip 插件 foreach 函数

jquery - 将导航栏顶部和导航栏侧面固定到屏幕上

Javascript 选项卡 - 如何在 URL 上添加主题标签?

javascript - 从 patosai 树多选中获取选中的选中值

c# - 没有注册类型 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' 的服务