当我突出显示“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/